CSS Universal Selector Tutorial
What is a Universal Selector?
The universal selector is an asterisk and applies the CSS rule(s) to all HTML elements in the document.
In the CSS code below, the universal selector has a property of "text-align" with a value of "right", meaning that all HTML elements in the document will be aligned to the right.
<style type="text/css">
* { text-align: right; }
</style>
The example below shows you the universal selector in action.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Web Development Tutorials.com</title>
<style type="text/css">
* { text-align: right; }
</style>
</head>
<body>
<p>
This is a paragraph
</p>
<p>
This is a paragraph.
</p>
<h3>
This is a heading.
</h3>
<h3>
This is a heading
</h3>
</body>
</html>
The code above creates the examples below.
This is a paragraph.
This is a paragraph.
This is a heading.
This is a heading.
Use the text editor below to practice what you have learned.