HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 30. ID 273


Example: We want to use “abc” as the ID. We want to identify a certain h2
heading with that ID. When we go to the webpage, we want that h2 heading
to be in view, even if it is far down the page.


The URL would behttp://(something).html#abc


The HTML would include


30.2 Cascading


The C in CSS stands for Cascading.


At any point on the webpage, the style depends on the tags that are in
effect, and the classes that are in effect, and the IDs that are in effect.


CSS has special rules for resolving any differences that might occur.


For example, if the body tag requests a yellow background, and within that,
the paragraph tag requests a green background, and with that, the span tag
requests a white background, the span tag will win because it is closest to
the actual words being colored.


Styles requested right inside the HTML take priority over styles requested
in the style sheet.


Styles requested in the style sheet have various priorities depending on how
specific the request was, and whether it is based on ID or class or tag.


The most specific request wins.

Free download pdf