|
Helping ordinary people create extraordinary websites! |
An Introduction to CSSBy Ben Hunt2007-12-17
On-page CSS definitions A better way to write CSS is to define your styles once in the document (preferably in the document <head> section). Code Looks like
I am affected by the definition above..
So am I, but the styles are only defined once.
The benefit of this over the previous approach is that the style definitions are only written once. In this case, they'd apply to any <div> elements on the page. Use this method when you want to apply similar styles to multiple elements on a page, but not on any other pages. To apply the same styles to things on multiple pages, you need to use method 3 below. Tutorial Pages: » The old way to style content » How CSS works » On-page CSS definitions » Separate style sheets » Advantages of separate stylesheets » How CSS styles apply to HTML elements |
|
<style type="text/css">
div {
background-color:#339;
color:#fff;
padding:15px;
border-bottom:5px solid red;
margin-bottom:15px;
}
</style>
</head>
<body>
<div>
I am affected by the definition above..
</div>
<div>
So am I, but the styles are only defined once.
</div>
</body>