HTML and CSS Refresher Challenges

Inheritance in CSS

Inheritance in CSS describes how elements inherit styles from its parent containers. If no value is specified for a property of an element, it will inherit it from its parent containers. For example, if a div container contains a paragraph, setting the font color of div will apply to all the elements inside the div. Thus, the font color of the paragraph will also change.

Specificity in CSS

Specificity in CSS describes how elements inherit styles that are the most specific. If multiple CSS styles apply to an element, the more specific style will be taken. For example, say there is some body element which contains a article which contains a paragraph. If the body is styled with blue text, the article with red text, and the paragraph with green text, the paragraph will take on the style of the most specific CSS and have green text.

ID and Class Attributes

The difference between ID and class is that ID's are unique to the element while classes describe a larger category of elements. While multiple elements can have the same class name, ID's are usually used only once per HTML page. Classes are kind of like more specific tags while ID's are like names.