Forum Moderators: not2easy

Message Too Old, No Replies

<h1> css problems

Stopping the heading tags creating a new line

         

PumpkinHead

10:21 pm on May 26, 2005 (gmt 0)

10+ Year Member



Hi all,

Hoping someone here can help! I'm trying to get whatever I have within my heading tags to stay on the same line.

My code..

Welcome to <h1 class="h1_welcome">Widgets</h1>!

.h1_welcome {
FONT-SIZE: 12px;
COLOR: #000000;
}

I'm trying to get this all on the same line:

Welcome to Widgets

But instead I get:

Welcome to
Widgets
!

Any ideas? It's probably something really simple. Hope this post makes sense, It's been a long day!

PH

natebates

10:29 pm on May 26, 2005 (gmt 0)

10+ Year Member



headings are block-level elements by default. the following fixes your problem

.h1_welcome {
FONT-SIZE: 12px;
COLOR: #000000;
display: inline;
}

PumpkinHead

10:59 pm on May 26, 2005 (gmt 0)

10+ Year Member



Thanks for the help natebates, and welcome to WebmasterWorld :)

encyclo

1:00 am on May 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to <h1 class="h1_welcome">Widgets</h1>!

The trouble is that you're using a block element as an inline one, with unknown consequences. An

h1
cannot be part of a paragraph. That leaves any text after the
</h1>
outside of a containing block.

You should put your resulting page through the HTML validator [validator.w3.org] to see how many errors this causes.

girish

1:03 am on May 27, 2005 (gmt 0)

10+ Year Member



wow, talk about an inproper use of the h1 tag. why wouldn't you just use the strong tag? Semantically what you're doing is absolutely incorrect.

kurtpdx

1:13 am on May 27, 2005 (gmt 0)

10+ Year Member



Sure, it's improper html, but keeping up with the Johnson's is tough, and adding H1 and H2 tags to your keywords is becoming quite standard.. don't hassle the guy for using the same tricks that everyone else uses. :)

Krapulator

6:06 am on May 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it to obvious to suggest using the h1 tag correctly:

EG: <h1 class="h1_welcome">Welcome to Widgets</h1>!

PumpkinHead

10:31 am on May 27, 2005 (gmt 0)

10+ Year Member



As kurtpdx mentioned, I'm just trying to get my keywords noticed, surely it would be better (with seo in mind) just to have my "Widgets" keyword within my h1 tags rather than "'Welcome to' Widgets"?

Robert2

2:23 pm on May 31, 2005 (gmt 0)

10+ Year Member



Welcome to <strong class="welcome">Widgets</strong>!

strong.welcome {
font-size: 150%;
color: black;
/* other styles to strongly emphasize */
}

createErrorMsg

2:54 pm on May 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



surely it would be better (with seo in mind) just to have my "Widgets" keyword within my h1 tags rather than "'Welcome to' Widgets"

Supposedly, there is an SEO benefit to having your keyword in your h1 tag. I'm unsure whether that benefit is diluted by the presence of non-keyword text. I would not think that the difference, if any, would be that much.

SEO benefit or not, your usage, as encyclo has pointed out, is the wrong usage, and is certain to continue giving you problems so long as you have a block level <h1> tag nested in a <p>aragraph, which according to specs [w3.org] can contain only inline elements.

cEM

PumpkinHead

9:16 pm on Jun 1, 2005 (gmt 0)

10+ Year Member



Thanks for the info all :)