How do I group declarations?
Author: Deron Eriksson
Description: This is a CSS example that demonstrates how to group declarations.
Tutorial created using: Windows XP


Page: < 1 2

(Continued from page 1)

The ungrouped declarations and the grouped declarations shown above all generate the same results. As a demonstration, the ungrouped declarations are featured in the following HTMLW file:

style-test-1.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Style Test 1</title>
<style type="text/css">
h1 { background: yellow; }
h1 { color: red; }
</style>
</head>
<body>
<h1>Howdy</h1>
</body>
</html>

The output of style-test-1.html is shown here:

display of style-test-1.html

The grouped declarations are featured in the style-test-2.html file.

style-test-2.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Style Test 2</title>
<style type="text/css">
h1 { background: yellow; color: red; }
</style>
</head>
<body>
<h1>Howdy</h1>
</body>
</html>

The output of this file is shown here:

display of style-test-2.html
Page: < 1 2