How to use !important in CSS Code Example

Last Updated On Wednesday 14th Jul 2021
  • The !important keyword is used to override all styles no matter their specificity or position in the stylesheet.

Syntax

	element {
    font-size: 1.2rem !important;
    font-weight: 500 !important;
}
	
  • The !important keyword is the easiest way to ruin the cascade of a stylesheet and make maintaining a stylesheet impossible.

Example

	h2 {
  color: green;
}

h2 {
  color: blue !important;
}