Open Playground
CSS TutorialLesson #9

Multiple Style Sheets

If some properties have been defined for the same selector (element) in different style sheets,

If some properties have been defined for the same selector (element) in different style sheets, the value from the last read style sheet will be used.

Example

Example Code

css
Try it Yourself
h1
{

  color: navy;

}

Example

Example Code

css
Try it Yourself
h1
{

  color: orange;

}

Example

Example Code

html
Try it Yourself
Live Output Preview:

Example

Example Code

html
Try it Yourself
Live Output Preview:

Cascading Order

What style will be used when there is more than one style specified for an HTML element?

All the styles in a page will "cascade" into a new "virtual" style sheet by the following rules, where number one has the highest priority:

  • Inline style (inside an HTML element)
  • External and internal style sheets (in the head section)
  • Browser default

So, an inline style has the highest priority, and will override external and internal styles and browser defaults.



Interactive Code Examples

Example 1

css
Try it Yourself
CSS syntax and property demonstration.
h1
{

  color: navy;

}

Example 2

css
Try it Yourself
CSS syntax and property demonstration.
h1
{

  color: orange;   

}

CSS Example 3

html
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 4

html
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview: