Forum Moderators: not2easy

Message Too Old, No Replies

headers

Is it possible to remove the line break after a header?

         

SoPretty

4:35 pm on May 5, 2005 (gmt 0)

10+ Year Member



As I want no extra space or line breaks in my headings, I have been using a span to define them.
ie. <span class="title">Heading</span.

In the interest of simplifying my code, I got the bright idea that I could just style the heading tags with no padding or breaks. Removing the space around them was done quite simply by setting the padding and margins to 0px but stopping the line break is another story. I have tried many combinations but am unable to get it to work. Is it even possible?

Another issue. Because I want no line break, I am attempting to insert my heading tags within a paragraph.
ie. <p><h1>heading</h1> text text text text text text text text text text</p>

The problem here is that I have styled the paragraph to have a specific color. When I insert a heading tag within the paragraph, the color styling is ignored and instead reverts to the default black. Can this be avoided?

Thanks in advance for any ideas! :o)

Matt Probert

4:46 pm on May 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, use the float parameter:

H1 { float: left; }

In a style sheet, to tell the browswer to put text following the </h1> termination tag on the same line as the preceeding <H1> text

Matt

SoPretty

4:54 pm on May 5, 2005 (gmt 0)

10+ Year Member



Yay, no linebreak! Thank you, Matt! :o)

Still need help with this:
When I insert a heading tag within the paragraph, the color styling is ignored and instead reverts to the default black. Can this be avoided?

Thanks all. :o)

SoPretty

5:11 pm on May 5, 2005 (gmt 0)

10+ Year Member



Ah, answered my own question.

Since the <h1> heading is now styled to float:left, I changed the placement of the <p> tag from:

<p><h1>Heading</h1>text text text text text text text text text text</p>
to:
<h1>Heading</h1><p>text text text text text text text text text text</p>

Now the colour of the <p> is no longer affected.

ronin

11:49 am on May 6, 2005 (gmt 0)

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



You could also style both the heading and the paragraph as inline elements:

h1, p#first {display:inline;}
p#first {margin-left:1em;}

<h1>My heading</h1>
<p id="first">My first paragraph...</p>

g1smd

10:32 pm on May 8, 2005 (gmt 0)

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



Headings are a block level element. You cannot have a heading inside a paragraph. It goes above it.

You can fiddle with the margin widths in the CSS to alter the spacing, and make it inline as above to get it on one line.