Lecture
Sometimes it is required to set simultaneously one style for all elements of a web page, for example, to set a font or a text style. In this case, the universal selector that matches any element of the web page will help.
An asterisk (*) symbol is used to denote a universal selector, and in general, the syntax is as follows.
* {Description of style rules}
In some cases, it is not necessary to specify a universal selector. For example, the entries * .class and .class are identical in their results.
Example 14.1 shows one of the possible applications of the universal selector - the choice of font and text size for all elements of the document.
Example 14.1. Using the universal selector
HTML5CSS 2.1IECrOpSaFx
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Универсальный селектор</title> <style> * { font-family: Arial, Verdana, sans-serif; /* Рубленый шрифт для текста */ font-size: 96%; /* Размер текста */ } </style> </head> <body> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam erat volutpat.</p> </body> </html>
Note that a similar result can be obtained if in this example you change the selector * to BODY.
1. What style will set the red color of the text in the paragraph?
2. What does the next entry in the styles mean?
* DIV * {background: green; }
3. To which word does the div * em * selector style apply in the following code snippet?
<div> <h1><em>Lorem</em> ipsum</h1> <p>Lorem ipsum dolor sit amet, <strong>consectetuer</strong> adipiscing elit.</p> <ul> <li><em>Ut</em> wisis enim ad</li> <li>Quis <em><span>nostrud</span></em> exerci</li> <li>Tution ullamcorper suscipit</li> </ul> <em>Nisl</em> ut aliquip exea commodo consequat. </div>
1. HTML * P {color: red; }
2. Set the background color for all elements inside the <DIV> container.
3. nostrud
Comments
To leave a comment
Cascading CSS / CSS3 Style Sheets
Terms: Cascading CSS / CSS3 Style Sheets