Ads by ProfitSence
Close

How to use !important in CSS Code Example

Last Updated on Wednesday 5th Oct 2022
  • 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;
}