The universal selector (*), matches the name of any element type. It matches any single element in the document tree. Some ways it can be used:
| * | matches any element |
| *.warning (equivalent to .warning) |
matches any element with class=warning |
| #id1 * | matches any descendendant of element with id=id1 |
| #id1 > * | matches any direct child of element with id=id1 |
Example – universal selector
<style>
#id1 * {
border: 1px solid lightblue;
}
</style>
<div id="id1">
<p>p1</p1>
<p>p2</p1>
</div>
<div id="id2">
<p>p3</p1>
</div>
Related
- CSS type selectors - define style by element name
- CSS attribute presence and value selectors
- CSS attribute substring selectors
- CSS class selectors - define style by class name
- CSS - style for element having two classes (both)
- CSS id selectors - define style by element id