The "Any" SelectorThe final type of selector in CSS2.1 is a selector that simply selects all elements. It can be used to set a property on all elements, but that is a rare occurrence. It can also be used in combination with the child selector to count ancestors. Here is an example of the "any" selector used on its own: * { cursor: auto } This resets the shape of the mouse pointer to the browser's default. This quickly undoes all changes to the mouse cursor. If the style sheet that comes with a document makes it difficult to find the hyperlinks, this might be a useful rule to have in a user's style sheet. Another place where the "any" selector might come in handy is in selectors that must match only at a certain depth in the document tree. For example, to select all paragraphs except those that are children of the BODY element, this rule will do this: BODY * P { font: medium "gill sans", sans-serif } This matches P elements that are descendants of any element that is a descendant of BODY. Therefore, it excludes P elements that are children of BODY itself. A final way to use the "any" selector is for purely aesthetic reasons. If you like all of your selectors to start with an element name, you can use the * in places where the element name doesn't matter: *[BORDER] { border: solid } *.POLONIUS { font-weight: bold } *:hover { color: inherit; background: inherit } In these cases, the "any" selector is used merely to avoid starting a selector with a flag character. It is a matter of taste. Table 4.2 summarizes all selectors in CSS2.1.
|