The Wayback Machine - https://web.archive.org/web/20081205124553/http://www.webreference.com:80/html/tutorial5/7.html


spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management

The CLASS attribute has a similar function with the ID attribute. The difference is that you can have more than one element in your document with the same CLASS, so you can refer to them as a group.

For instance, let's say that we want some paragraphs in our document to have one kind of rendering and others a different kind of rendering. Here's our HTML document body:

<BODY>

<H1>Acme Computer Corp.</H1>

<P CLASS=special>Acme Computer Corporation is a
technology-based company that seeks to offer 
its customers the latest in technological 
innovation. Our products are created using the 
latest breakthroughs in computers and are designed
by a team of top-notch experts.</P>

<H1>Global Presence, Global 
Thinking</H1>

<P CLASS=special>We are based in Acmetown, USA, 
and have offices in most major cities around 
the world. Our goal is to have a global approach 
to the future of computing.</P>

<P>This Web site is where you can find
information on our products and the technologies 
we use and develop daily. You can browse our 
product catalog, order products online, read 
technical manuals published by Acme Press, and 
read press releases and other information about
ACC.<P>

<H1>What's New</H1>

<P CLASS=news>Dr. Arnold D. Propellerhead's
best-selling book, <cite>Transfirbulation
Technology</cite>, is now <a
href="books/OTP/">available
online</A> in its entirety. 
This book is a must-read for anyone interested 
in Object Transfirbulation and is the perfect 
companion for Acme's top-of-the-line Name
Sequencer, M.O.R.O.N.S.<P>

<P CLASS=news>Acme Computer Corp. has just
acquired ThinkMeUp, Inc., the industry leader 
in Object Costrabulation. This bold business 
move promises a combination of Acme's experience 
in Transfirbulation with TMU's exciting 
Constrabulation technology. 
<a href="news/TMUto.html">Read the 
full press release</A>.<P>

<HR>

<ADDRESS>
Comments to: 
<A HREF="mailto:webmaster@acme.com">Web Master</A>, 
Acme Computer Corp., One Acme Road, AcmeTown, USA.
</ADDRESS>

</BODY>
</HTML>

And here's a stylesheet for it:

P.special {
 font-size: bigger;
}
P.news {
 font-family: sans-serif;
 color: #0000A0;
}

Now the first two paragraphs, which belong to the class "special," will have the rendering specified after the first selector, and the remaining two will have the style specified after the P.news selector. Like the ID selector syntax, CLASS selectors consist of an optional element name followed by a period (.) and a class name. Omitting the element names, the style sheet comes out like this:

.special {
 font-size: bigger;
}
.news {
 font-family: sans-serif;
 color: #0000A0;
}

Here, however, there is a difference between the two stylesheets. In the case of ID, there can be only one element in a document with the specified ID, so leaving out the element name doesn't change the elements the selector matches. Here, however, any element can have a class of, say, "special," so specifying in the selector that the selected element must also be a paragraph narrows the scope of the selector.

I know you're itching to see this example in action, so here it is.

Front Page12345678910

http://www.internet.com

Produced by Stephanos Piperoglou

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Copyright 2008 Jupitermedia Corporation All Rights Reserved.

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Symantec Whitepaper: Converging System and Data Protection for Complete Disaster Recovery
Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
  Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A; with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Symantec Whitepaper: Comprehensive Backup and Recovery of VMware Virtual Infrastructure
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Administering MySQL Databases on the Web Using PHP · Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
So what is an Oracle Nested Table? · E-Discovery Architectures 101 · eBay Embraces Big Sellers, Cyber Monday Trends


All Rights Reserved. Legal Notices.

URL: http://www.webreference.com/html/tutorial5/7.html
Created: August 20, 1998
Revised: August 20, 1998

Morty Proxy This is a proxified and sanitized view of the page, visit original site.