CSS * Selector
The * selector in CSS is used to select all the elements in an HTML document. It also selects all elements which are inside under another element. It is also called the universal selector.
Syntax:
* { // CSS property }
Example 1: This example shows the use of the CSS universal selector.
HTML
<!DOCTYPE html> < html > < head > < title >* Selector</ title > <!-- CSS property of * selector --> < style > * { color: green; text-align: center; } </ style > </ head > < body > < h1 >w3wiki</ h1 > < h2 >*(Universal) Selector</ h2 > < div > < p >GFG</ p > < p >Beginner</ p > </ div > < p >It is a computer science portal for Beginner.</ p > </ body > </ html > |
Output:
Example 2: This example shows the use of the CSS universal selector.
HTML
<!DOCTYPE html> < html > < head > < title >* selector</ title > <!-- CSS property for * selector --> < style > * { background: green; font-weight: bold; margin-left: 70px; color: white; } </ style > </ head > < body > < h1 >w3wiki</ h1 > < h2 >*(Universal) Selector</ h2 > < ul > < li >Data Structure</ li > < li >Computer Network</ li > < li >Operating System</ li > </ ul > < ol > < li >Java</ li > < li >Ruby</ li > < li >Pascal</ li > </ ol > </ body > </ html > |
Output:
Supported Browsers: The browser supported by *(universal) selector are listed below:
- Apple Safari 3.1
- Google Chrome 4.0
- Firefox 3.0
- Opera 9.6
- Internet Explorer 7.0
Contact Us