Week 3 Review questions for CSS class
Just two questions. Easy week.
-
Please provide an example of a pseudo-class.
When might they be used and when should they be avoided?
- A pseudo-class style is a style that
is not determined solely by the structure of the document. For example, the style might also depend on the state and/or
history of the page as it is viewed in the browser. The classic examples are the a:hover pseudo
class that depends on the dynamic state of the page -- is the mouse over the hyperlink and the a:visited
pseudo class that depends on whether the link has been clicked on or otherwise followed (more to the point is the URL
in the cache). Pseudo-class styles are not supported uniformly by different browsers, so if a consistent
browser-to-browser behavior is important, then they should be avoided. One thing particularly to be avoided are changes
that affect the page's flow
This page uses the following pseudo class that affects the hyperlinks
a:link {
background-color:transparent;
color: #333366;
text-decoration: none;
}
a:visited {
background-color:transparent;;
text-decoration: none;
color: #333366;
}
a:hover {
text-decoration: underline;
background-color:#ffccff;
color: #663333;
cursor: pointer;
}
a:active {
text-decoration: none;
color: #663333;
background-color:#ffccff;
}
-
Please provide an example of a pseudo-element.
When might they be used and when should they be avoided?
- A pseudo-element makes the browser react as if there were an additional element in the document. For example, the p:first-letter pseudo element will have the browser act as if there is an additional tag and its associated style surrounding the first letter (and only the first letter) within a paragraph block. They make the browser act as if that extra code was there without it being there. Thus if more text were added at the beginning of a paragraph, the adjustment would automatically be made. Like pseudo-class styles, pseudo-element styles are not supported uniformly by different browsers, so if a consistent browser-to-browser behavior is important, then they should be avoided. For example, if the additional information provided by a :after or :before pseudo element is crucial, then it should not be left up to this technique to be displayed.
This page uses the following pseudo element that affects the first line of the list items of the ques class
li.ques:first-line
{
font-size: 1.5em;
}