The universal selector is denoted an asterisk (*). When used alone, the universal selector will tell the web browser to apply the CSS rule to all elements in the document.
ID selectors are similar to class selectors, except ID selectors are meant to be used only once per document. An id selector is preceded by a hash mark (pound sign), followed by the id name. The hash mark appearing before the class name in the CSS rule tells CSS that you are referencing the id selector.The id name is typically comprised of letters, numbers and hyphens only, since this provides the best compatibility with older web browsers. ID names cannot include spaces.
NOTE: Do NOT start an ID name with a number! It will not work in Mozilla/Firefox.
The CSS and XHTML example is an example of an id 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">
*
{
border: 1px solid red;
color: green;
}
</style>
</head>
<body>
<h1>
This is a heading
</h1>
<p>
This is a paragraph.
</>
<p>
This is another paragarph.
</p>
</body>
</html>
The code above would create a this web page. Notice that every HTML element on the web page has a red border and all of the text is green.
Use the text editor below to practice what you have learned.