3) Universal (*)
Select all elements,
and set their background color, font color or any other.
Syntax
*
{
declarations;
}
<html>
<head>
<style>
*
{
background: silver;
color: blue;
font-family: Arial, Helvetica,sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to My Homepage</h1>
CSS universal selectors select any type of elements in an HTML page. It matches a single element. An asterisk ( i.e. "*" ) is used to denote a CSS universal selector. An asterisk can also be followed by an selector. This is useful when you want to set a style for of all the elements of an HTML page or for all of the elements within an element of an HTML page
</body>
</html>
<html>
<head>
<style>
*.warning
{
color:red;
}
*#maincontent
{
border: 3px solid blue;
}
</style>
</head>
<body>
<h1>Welcome to My Homepage</h1>
<p class="warning">
<span> A red class </span> in a red paragraph.
</p>
<p id="maincontent">
<span class="warning">A red class with border blue id</span> in a green paragraph.
</p>
</body>
</html>
No comments:
Post a Comment