Forum Topic: Css Style Sheets Affect Headers?

(151 views • 6 replies)

This topic is 1 page long.

<< < > >>
None

Nickapassa

Reply To Post Reply & Quote

Posted at: 10/18/09 12:56 AM

Nickapassa LIGHT LEVEL 06

Sign-Up: 09/04/09

Posts: 145

I have a site, and I was wondering, if I use a CSS Style Sheet on my page would it, let's say affect all header 2 sections, and turn them blue instead of black?
If it's in the Style Sheet?

What is life with no creativity?
Nickapassa on the web!

BBS Signature

None

Jessii

Reply To Post Reply & Quote

Posted at: 10/18/09 09:45 AM

Jessii DARK LEVEL 36

Sign-Up: 02/10/05

Posts: 9,180

If you do a .h2 {} class, then yes it'll affect all of those <h2></h2> tags.


None

Jessii

Reply To Post Reply & Quote

Posted at: 10/18/09 11:16 AM

Jessii DARK LEVEL 36

Sign-Up: 02/10/05

Posts: 9,180

At 10/18/09 09:45 AM, Jessii wrote: If you do a .h2 {} class, then yes it'll affect all of those <h2></h2> tags.

Actually I stated this wrong. The above example is wrong if you want to affect all of the h2s. If you want all of the h2s to be the same, you want to use h2 {whatever you want here} as a CSS declaration. If you only want a few of them to be affected, then you can do something like .h2 {font:;} and declare the class in your html.


None

smulse

Reply To Post Reply & Quote

Posted at: 10/18/09 11:43 AM

smulse EVIL LEVEL 30

Sign-Up: 03/24/05

Posts: 5,928

I'd advise against calling a class the same name as an element, ie
.h2 { }
h2 { }
there's very little difference between them, it's going to be easier to error check and distinguish between them if they are different. Plus, there's probably no need to even add a class to them, just be clever with your selector in the CSS and do something like

#mainCol h2 { }

That would select all h2's in the #mainCol div, but none of the others. It's much cleaner.

BBS Signature

None

CronoMan

Reply To Post Reply & Quote

Posted at: 10/19/09 05:31 AM

CronoMan EVIL LEVEL 06

Sign-Up: 07/19/04

Posts: 2,987

I'd suggest you should change the H's to match the design of the website
Making classes and defining special elements in special area's for the H's is unnecessary. You could just as well use

<span class="fdsa">fdsa</span>

instead of using the H's, if some special rule applies. If you also have a wysiwyg-editor for your site, it's a pain in the ass to apply specific classes for specific columns or whatever. The more generic the CSS file is, the better - so you won't have a billion lines of CSS to maintain. H's are headers for text, they should look the same across the page

"no sound in ass"


None

smulse

Reply To Post Reply & Quote

Posted at: 10/19/09 07:06 PM

smulse EVIL LEVEL 30

Sign-Up: 03/24/05

Posts: 5,928

At 10/19/09 05:31 AM, CronoMan wrote: Making classes and defining special elements in special area's for the H's is unnecessary. You could just as well use
<span class="fdsa">fdsa</span>

If you were referring to me (?), I was meaning that there is probably already a wrapper div, or similar, in which all the header tags he wants to effect are in. Thus

#whatever-element-headers-are-in h2 { foo: bar; }

I was saying there was no need to add any extra html markup.

Also, i'd advise against using a span, p, or similar tag for a header. Why? Because they're not meant for headers. H1-H6 tags are. Might as well have the extra SEO kudos.

BBS Signature

None

urbn

Reply To Post Reply & Quote

Posted at: 10/19/09 08:47 PM

urbn FAB LEVEL 18

Sign-Up: 06/10/07

Posts: 2,301

I suppose if you HAD to replace H tags with something, it would be better starting it with a div as H tags are block displayed (IIRC). Though as smulse said you would loose the SEO.

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 08:24 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!