H151 Week #3 Review Questions

1. Please provide an example of a pseudo-class. When might they be used and when should they be avoided?
A: A pseudo-class like :first-child is used to apply style rules based on the structure of the document, without creating a specific class in the HTML code. According to the textbook the pseudo-classes that apply to links should be avoided when they require dynamically re-rendering the document, for example: a:hover {font-size: bigger;}

2. Please provide an example of a pseudo-element. When might they be used and when should they be avoided?
A: A pseudo-element like :first-letter introduces a "phantom" element into the HTML code surrounding the first letter of the selected element, allowing style rules to be applied only to that letter and it's opening punctuation. Pseudo-elements like :before and :after should not be used to introduce large amounts of text (as I did in my slightly contrived example for this week's project) since this violates the separation of style from content.