Forum Moderators: not2easy

Message Too Old, No Replies

Making h2 different on separate pages

         

zonkd

9:38 am on Oct 26, 2005 (gmt 0)

10+ Year Member



I'd like <h2> to be 20px on one page, but 16px on another.

Is there a common way to change the look between web pages when the h tags are all defined in my css stylesheets, please, Gurus?

alias

10:02 am on Oct 26, 2005 (gmt 0)

10+ Year Member



There are lost of ways to accomplish that.

You can assign different classes for the headings on the pages like:

<h2 class="small"> or <h2 class="bigger">

Then you just modify the css: h2.small {font-size: 16px;}

Or you can assign different classes or ID's to the pages themselves like:

<body id="page1> or <body id="page2">

The css in that case would be something like that:

#page1 h2 { font-size: 16px; }
#page2 h2 { font-size: 20px; }

And so on.

zonkd

12:59 pm on Oct 26, 2005 (gmt 0)

10+ Year Member



Much obliged to you, alias ... but it doesn't work for me.

Well, if I put the <h2> class in the same ss (style-sheet) as the declared <h2>, the browser seems to pick up my original and use it. If I put it into another ss, I have to have an alternative ss for my first ss - if you follow me. In other words, unless I remove my original <h2> completely, the browser will use it.

The risk of many stylesheets is that it will become confusing for anyone who takes over from me.

What about declaring it on the page itself, do you think? And if that might work better, I suppose that declaration would go in the <head> section.

If the browser reads it AFTER the style-sheets, perhaps it would accept that one as the version I want.

Fotiman

2:14 pm on Oct 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



> Well, if I put the <h2> class in the same ss (style-sheet) as the declared <h2>, the browser seems to pick up my original and use it.

Your rules should look something like this:


h2 { font-size: 20px } /* This is your default */
#page1 h2 { font-size: 20px; } /* Could ommit this since it matches the default */
#page2 h2 { font-size: 16px; } /* Override the default */

> If I put it into another ss, I have to have an alternative ss for my first ss - if you follow me. In other words, unless I remove my original <h2> completely, the browser will use it.

With the example above, that should not be the case (assuming you remember to give your body id values "page1" and "page2").

> What about declaring it on the page itself, do you think? And if that might work better, I suppose that declaration would go in the <head> section.

There's no need. It should work in the same stylesheet.

Hope this helps.
-Peter

zonkd

1:53 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



Thanks, Peter. I'll give it a try. Much obliged for your explanation, and for alias's.