From the course: CSS Fundamentals: Unlock the Power of Web Styling

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Considering the rule !important

Considering the rule !important

- [Instructor] In CSS, you can apply the !important property to add more weight or importance to a property value pair than normal. For instance, in terms of the cascade, we know that, selectors being equal, the last rule specified takes precedence over any previous declarations. So in this instance, our text is orange because the second h1 declaration overrides the first. But what if we add !important to the declaration? Well, in this case, our heading is blue. Applying !important to the declaration is a very powerful way to ensure that a particular style is applied. So when should you use it? A common-use case is when you're working with code that you don't have control over. For instance, maybe you're embedding some code from a third party site, like a HubSpot form, a YouTube video, or a real estate listing. The in embed code may contain styles that you have no control over. Having !important in your toolbox allows…

Contents