![]() |
|||||||||||||
|
|||||||||||||
|
Javascript Code Library |
|
Attributes
Class and ID
Classes let you create grouping schemes among styled HTML tags by adding the style definition of a particular class to the style definitions of several different tags. In the stylesheet, a class name is preceded by a period (.) to identify it as such:
<style>
P {font-family: sans-serif; font-size: 10pt}
</style>
The tags and classes can then be used in combination:
<h1 class="red">This is rendered as 30-point red serif text.</h1>
<p class="red">This is rendered as 10-point red sans-serif text.</p>
Or not:
The ID attribute is used for a uniquely defined style within a stylesheet. In the stylesheet, an ID name is preceded by a hash mark (#) to identify it as such:
#foo {property 1: value 1; property 2: value 2}
Text-Level Attributes: <SPAN> and <DIV>
The <span> tag is generally used to apply a style to inline text:
The <div> tag is generally used to apply a style to a block of text, which can also include other HTML elements:
<div class="foo">
The style attribute provides a way to define a style for a single instance of an element:
The class, ID, and style attributed can be applied within the <span> and <div> elements. Used with class or ID, the <span> and <div> tags work like customized HTML tags, letting you define logical containers and apply a style to their contents.
- What Is CSS?
CONTENTS
OTHER RESOURCES
Editorial Policy
|
Help
|
Feedback
|
About Terra Lycos
|
Jobs
|
Advertise
|
Business Development Copyright © 2001 Lycos, Inc. All Rights Reserved. |