Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newvbie Definition 3

Status
Not open for further replies.

clivehenderson

IS-IT--Management
Nov 2, 2002
66
GB
Hi I'm just starting to use CSS divisions and have managed to layout my webpages without tables.(using dreamweaver so not really handcoding))
Id like certain divisions/setctions to have different H1 and H2 settings but can't figure out how to do it.

Can anyone help please or point me to a dummys guide?
Any help appreciated
Many thanks Clive

 
Hi

Use selector. The simplest is to use [tt]class[/tt] :
CSS:
h1 {
  color: blue;
}
h1.important {
  color: red;
}
h1.interesting {
  color: green;
}
HTML:
<h1>Nothing special, just blue</h1>
<h1 class="important">So important that is red</h1>
<h1>Just blue again</h1>
<h1 class="interesting">No better idea, just green</h1>

Feherke.
 
You can also put the class on the DIV itself, for example if all headings inside a particular DIV need to be red, etc:

Code:
div.important h1,
div.important h2 {
   color: red;
}

...

<div class="important">
   <h1>Whatever</h1>
   ...
   <h2>Whatever</h2>
</div>

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
A better option for what you are asking (I think that's what you're asking) is to use descendant selector:
Code:
#navigation h1 {
  color: red;
}

#content h1 {
  color: blue;
}
This code says that all h1 elements within a #navigation element will be colored red. All h1 elements within #content will be blue. This assumes you have other elements with the corresponding id elements within your html code.

[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top