background: #666; Table cells inside larger elements will have orange text on a gray background. (A larger element named fancy might be a table or a div.)
In the above example, the table cell with class name fancy will be orange with a gray background.
Multi-category selector
1. In HTML, a class value may contain a list of words, with each word separated by spaces. For example, if you want to mark a specific element as both important and warning, you can write (the order of the two words does not matter, you can also write warning important):
This paragraph is a very important warning.
We assume that all elements with class important are bold, and all elements with class warning are italic, and all elements with class containing both important and warning are also There is a silver background. You can write:
.important {font-weight: bold;} .warning {font-weight:italic;} .important.warning {background:silver;}
2. By linking two class selectors Together, only elements containing both of these class names can be selected (the order of the class names is not limited). If a multi-class selector contains a class name that is not in the class name list, the match will fail. Please see the following rules:
.important.urgent { background:silver;}
As expected, this selector will only match p elements whose class attribute contains the words important and urgent. Therefore, if a p element has only the words important and warning in its class attribute, it will not match. However, it does match the following elements:
This paragraph is a very important and urgent warning.
|