How to reset/remove all styles from an element in CSS?

How to reset/remove all styles from an element in CSS?

  • CSS
  • 2 mins read

Introduction

CSS styles can be applied to elements on a web page to control the layout, color, and other visual aspects of the page. However, sometimes it may be necessary to remove or reset all of the styles that have been applied to a particular element. This tutorial will show you how to do this using the CSS all property.

The CSS "all" property

The all property is a shorthand property that can be used to reset or remove all CSS styles that have been applied to an element. This property is often used to reset the styles of an element to their default values before applying new styles.

Example 1: Resetting all styles to their default values

To reset all styles to their default values, you can use the all property with the value initial.

element {
  all: initial;
}

Example 2: Removing all styles

To remove all styles, you can use the all property with the value unset.

element {
  all: unset;
}

Conclusion

In this tutorial, you have learned how to use the CSS all property to reset or remove all styles from an element. By using this property, you can easily reset the styles of an element to their default values or remove all styles completely, making it easier to apply new styles to the element.

Related: