Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: All
Jan 20, 2000

Use Style Grouping for Leaner HTML

The HTML Style syntax lets you apply the same style attributes to a group of tags at the same time. You don't need to define each tag's styles separately. The following code uses the H1, H2, H3 and H4 tags in the body. However only H1, H2, H3 and H5 use the same style. Note that commas in the Style section separate tag names. In addition to making HTML code leaner, grouping makes styles easier to maintain.

 
<html>
<head>
<title>Style Grouping</title>
<style>
P {font-family: serif;}
H1, H2, H3, H5 {color: purple;
 font-family: Arial,sans-serif;}
</style>
</head>
<body>
<h1>Heading 1</h1>
<blockquote>
  <h2>Heading 2</h2>
  <blockquote>
    <h3>Heading 3</h3>
    <blockquote>
    <h4>Heading 4</h4>
    </blockquote>
  </blockquote>
</blockquote>
    <p>Regular text</p>
    <p> </p>
</body>
</html>
Ken Cox
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap