tags:

views:

753

answers:

5

Hi, I'm trying to have <hx> tags inside paragraphs, like:

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam pulvinar tincidunt neque, at blandit leo mattis vitae. Cras <h2>placerat</h2> justo vel risus porta cursus. Nullam eget sem nibh. Sed <h3>mattis</h3> facilisis rhoncus. Morbi sit amet nisl lectus.</p>

But I always get a line break before each one of them, even applying all these, and combinations of the following declarations:

h1, h2, h3, h4, h5, h6 {
display:inline !important;
text-transform:none;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
font-family: inherit;
clear:none;
color:inherit;
margin:0;
padding:0;
}

So what can I do so that the tags go unnoticed inline with the text? Right now I get something like

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam pulvinar tincidunt neque, at blandit leo mattis vitae. Cras

placerat justo vel risus porta cursus. Nullam eget sem nibh. Sed

mattis facilisis rhoncus. Morbi sit amet nisl lectus.

Thank you

PS: btw I'm using blueprint framework theme for drupal.

A: 

See this please.

Demo

Sarfraz
He already has `display: inline`.
SLaks
The examples you provide are good when you need the h1 tags at the beginning of the paragraph (and that I have already accomplished), but I need them in the middle of a paragraph.
Alextronic
+9  A: 

You're misusing the header tags.

You should use <span> tags with CSS classes.

I tried it out, and what's happening is that when Firefox sees an invalid <h1> tag inside the <p>, it automatically closes the <p> tag. You can clearly see this in Firebug.

SLaks
Some search engines know about "off-the-beaten-path" techniques for SEO and flag sites to delist them. I would stick with using the correct semantics and use other methods to maximize your rankings.
tahdhaze09
"...the SEO agency has given us this direction." Then your SEO agency is staffed with idiots (or fools).
Traingamer
"CSS classes" -- Classes are HTML attributes. CSS can select elements using them as a piece of criteria, but they exist in HTML.
Anonymous
@Alextronic Cancel your contract with this SEO firm immediately! They are selling you information and advice that is absolutely untrue and if anything you will lose more than money from this advice. I highly recommend posting on the SitePoint forums as some of the regular users there are extremely knowledgeable with SEO and will steer you in the right direction, or can point you in the direction of someone to hire that really knows what they are doing.
EnderMB
A: 

You can't!

You can only use the -tags ahead of the paragraph. If you want to resize your text, you should use a text-tag ;-)

SiteSafeNL
+3  A: 

The <p> tag can only contain inline elements. The header tags are block-level elements, and cannot go inside <p> tags even when you style them to display inline.

They're semantically incorrect given this usage anyways - paragraphs shouldn't have headers randomly floating around inside them. Consider proper use of <em> and <strong> tags, or if they're really not what you're trying to describe, use <span> tags with specific classes.

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam
pulvinartincidunt neque, at blandit leo mattis vitae.
Cras <em>placerat</em> justo vel risus porta cursus. Nullam eget
sem nibh. Sed <strong>mattis</strong> facilisis rhoncus. Morbi sit
amet nisl lectus.</p>
meagar
Using em, strong and span will allow you to give specific styles to those elements without having incorrect semantic markup.
Chris
Please see my comment to SLaks answer. Thanks.
Alextronic
+1  A: 

SLaks is right. You should not use heading in paragraph. However, if you really needed it (in case it is written by someone else). You can solve the problem by setting p to be inline too. That will work.

NawaMan
Actually, that won't work. See my edit.
SLaks
I am sure it works. Please see here http://dl.dropbox.com/u/1961549/StackOverflow/HeadingInline/Test.html.
NawaMan
This sounded promising, but if I set 'p' to be inline, when a paragraph ends, the next paragraph will follow in the same line instead of creating a new one (with paragraph break I mean), hence resulting in a long text without separations.How did you accomplish to get rid of that effect in your demo?
Alextronic
As you can see from the code (Ctrl+U in Firefox) that is all I did. It is strange that it didn't work for you. I test this on FF, Chrome and Konqueror and they all works. I also use your example paragraph.
NawaMan
You're right, NawaMan. Don't know why it didn't work for me. There must be something in my css still influencing over 'p' and 'hx' tags even when I¡m setting them to 'inline !important'. Weird! I have checked blueprint theme's declaration of the 'p' element and it goes like this: 'p {margin:0 0 1.5em;}', and somewhere else: '{vertical-align:baseline;}', so I don't know what else can be.
Alextronic