Review Questions 2
- In the figure above, item 5 is a(n)
ID definition.
- In the figure above, item 4 is a(n)
class definition.
- What are some advantages of using id over class? Please reference your response.
For example, if you found the information at an online source, indicate the URL; if you used the text, list the page;
or if you just knew, state that.
The ID carries a higher weight of importance compared to a class.
In the rules of "The Cascade" it would override a class definition if they were both specified in the same style sheet.
Referenced from the CSS Online class lecture and the required reading book (pages 35 and 49)
- What are some advantages of using class over id. Please reference your response.
The ID definition should be unique within an html document whereas a class definition can be applied to any number of elements.
References required text (pages 34 and 35)
- Please provide some examples of pseudo-classes and pseudo-elements.
When might you use these CSS features? And when should they be avoided? Please reference your response.
There are only three pseudo-classes in CSS1:
:link
:visited
:active
These all apply to the Anchor element in HTML, hence
A:link
A:visited
A:active (not supported in NN4.x or O3.x)
These would be used whenever you wished to change the default anchor colours, for isntance if you had a blue background, the default anchor colour of blue would not enable your links to be seen, changing this to yellow or green would enable your links to be seen. Reference required text (pages 36 and 37)
CSS1 has two pseudo-elements:
:first-letter
:first-line
these can be applied to the first letter or line of a block level element such as a paragraph or heading, allowing style and colour changes only to this portion of the text.
Reference required text (pages 39 and 40)
Note that there are restrictions on pseudo-class and pseudo-element selectors (listed on page 41 of the required text) and that the pseudo-class or element are always the very last thing int he selector, coming after the element, class and/or ID.