If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Grouping & contextual

(2) If several elements have the same style rule, you can group these selectors together in a comma-delineated list. You could also use a wildcard * asterisk for all elements. For instance, CSS elements are display: inline by default. Browsers have applied display: block to things we think of as block-level (headers, paragraphs, etc.). Since browsers have not yet set styles for new HTML5 elements you might want to

Contextual Selectors
You can use contextual selectors to indicate the context of a selector. The context of a selector is determined by what its parent element is. In other words, what the element is nested within or what precedes it in the document.

For instance, if you wanted to have some form of special formatting for unordered lists inside ordered lists, you could write:

ol ul { ... }

This can be read as "for any unordered list that is nested within an ordered list." Thus they style rule will only apply to unordered lists inside ordered lists.

5.5 Descendant selectors
At times, authors may want selectors to match an element that is the descendant of another element in the document tree (e.g., "Match those EM elements that are contained by an H1 element"). Descendant selectors express such a relationship in a pattern. A descendant selector is made up of two or more selectors separated by white space. A descendant selector of the form "A B" matches when an element B is an arbitrary descendant of some ancestor element A.

For example, consider the following rules:

h1 { color: red } em { color: red }

Although the intention of these rules is to add emphasis to text by changing its color, the effect will be lost in a case such as:

<H1>This headline is <EM>very</EM> important</H1>

We address this case by supplementing the previous rules with a rule that sets the text color to blue whenever an EM occurs anywhere within an H1: