The *
selector selects all elements.
The universal selector does match every element in the document,
including the html
and body
elements.
*
selector can be used to add style for
all elements inside another element.
div *
* { style properties }
* |
Yes | Yes | Yes | Yes | Yes |
An example showing how to use * CSS selector.
<!DOCTYPE html>
<html>
<head>
<style>
* {<!-- w ww. j ava 2 s .co m-->
background-color:red;
}
</style>
</head>
<body>
<h1>heading</h1>
<p>Paragraph.</p>
</body>
</html>
Select all element inside a div
<!DOCTYPE html>
<html>
<head>
<style>
div *<!-- w ww .j ava2s . c o m-->
{
background-color:red;
}
</style>
</head>
<body>
<h1>header</h1>
<div>
<p>paragraph in a div.</p>
</div>
<p>Outside div.</p>
</body>
</html>