Chapter 18 Answers
To import one style sheet into another you use the
@importdirective, like this:@import url('styles.css');.To import a stylesheet into a document, you can use the HTML
<link />tag, like this:<link rel='stylesheet' type='text/css' href='styles.css' />.To directly embed a style into an element, use the
styleattribute, like this:<div style='color:blue;'>.The difference between a CSS ID and a CSS class is that an ID is applied to only a single element, whereas a class can be applied to many elements.
In a CSS declaration, ID names are prefixed with a
#character and class names with a.character, as in#myidand.myclass.In CSS the semicolon is used as a separator between declarations.
To add a comment to a stylesheet, you enclose it between
/*and*/opening and closing comment markers.In CSS you can match any element using the
*universal selector.To select a group of different elements and/or element types in CSS, you place a comma between each element, ID, class, etc.
To make one CSS declaration of a pair with equal precedence have greater precedence over the other one, you append the
!importantdeclaration to it, like this:p { color:#ff0000 !important; }.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access