CSS TutorialLesson #109

CSS Specificity

CSS specificity is an algorithm that determines which style declaration is ultimately applied to an element.

CSS specificity is an algorithm that determines which style declaration is ultimately applied to an element.

If two or more CSS rules point to the same element, the declaration with the highest specificity will "win", and that style will be applied to the HTML element.

Look at the following examples:

Example

Example Code

html
Try it Yourself
Live Output Preview:

Now, look at next example:

Example

Example Code

html
Try it Yourself
Live Output Preview:

Now, look at next example:

Example

Example Code

html
Try it Yourself
Live Output Preview:

Now, look at next example:

Example

Example Code

html
Try it Yourself
Live Output Preview:


Interactive Code Examples

CSS Example 1

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

CSS Example 2

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

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: