HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 34. UNTANGLING HTML AND STYLE 290


This works wonderfully well in many cases.


It is especially wonderful because a new style can be introduced throughout
your website by simply replacing the style sheet. All the webpages will refer
to the new sheet.


The next most general solution is to style an individual webpage. Instead
of having a file that is shared, the styling information can be embedded into
the webpage, usually as part of the.


This is called an internal style sheet.


When a style is specified in both an external style sheet and an internal style
sheet, the internal style sheet takes priority.


The most specific solution is to style an individual tag within a webpage.
This is done by using thestyle="..."attribute of the tag.


This is called an in-line style.


When a style is specified by in-line style as well as external or internal style
sheet, the in-line style takes priority.


34.3 Specificity


When a style is specified in several different places, the most specific place
takes priority.


Thus, an in-line style always takes precedence over everything.


But within style sheets, both internal and external, specificity can be calcu-
lated to resolve which style will be applied.


ID is more specific than class. Only in-line is more specific than ID.


Class is more specific than tag.


todo: add more content

Free download pdf