tags:

views:

117

answers:

2

I have a block of text, and inside the block I have an h1 tag floated left. I would like the first line of text to align with the bottom of the first line of text.

Here is the sample site:

http://myhealthsense.abyteshosting.com/

The block in question is the block under the header that says "Welcome! I am a..."

I want the 'Welcome!' to have it's bottom aligned with the rest of the sentence, and for the next line to wrap under the 'Welcome!'. As it is now, there are two lines wrapped to the right of 'Welcome!'.

Of course I could do this easily if all the text was together in a line, and I could use spans to set the sizes. But, since this is all generated out of drupal, the content comes as it is. In other words, the text in the block comes from the database, and is generated in a div, but the 'welcome!' has to be in the template. If I put it in the content div, my user will mess it up every time they edit the content.

Any hints are appreciated.

A: 

You could put your text in <p></p> and specify display:inline; for both h1 and p. IE:

<h1>Welcome!</h1><p>Mytext here</p>

Then a float is unnecessary.

edl
Ah.. sorry, I finished reading the rest of your question. :) I guess it depends on what parts of the structure you have control over.
edl
yeah, I'm starting to think that I will have to get real hacky with this with absolute positioning and padding tricks.
Cliff
A: 

The <h1> is semantically incorrect for this usage. <h1> is a semantic tag used to indicate the title of an article or primary section of content. In this case you are attempting to use the <h1> tag to alter the presentation of the text rather than the purpose of it. For this, you would be better served by using the span tag and assigning a class style:

<p><span class="welcome">Welcome!</span> blah blah blahbitty blah</p>

Different idea:

Add a line-height to the first line of your paragraph tag to be equal to your Welcome line's expected height:

p:first-line 
{
    line-height: 1.5em;
}

This might cause an odd space in some browsers I think (I haven't tried it out yet).

Another idea:

You could add a style with top-padding to the block element you're using for your primary content area. This would prevent text from starting until it is ready to start. Keep in mind this approach adds this padding to the overall size of the block element, so a block element with a height of 100px and a top padding of 20px will actually be 120px.

Joel Etherton
Personally, I think "welcome" works as a "primary section of content." To each his own though. :)
edl
That's all well and good, but it doesn't address my problem at all. I have no problem styling a snippet like you presented above with my text all bottomed aligned, but the issue here is that I have a block of text in a div, and my 'Welcome!' string _can not_ be in it. It can be a h1, or a div, or a span, or whatever I like, but it needs to be floated left in my text div and then bottom align with the first line of text in that div.I've changed my example page to a span, however, but it doesn't change my problem.
Cliff
and, yes, I thought 'welcome' qualified for h1 use, but it doesn't matter much.
Cliff
I can't load your page for some reason, it just returns gibberish. However, given the template nature of what you're doing, I will edit with a different idea.
Joel Etherton
the line height looks promising, let me try that and get back to you. Thanks.
Cliff
The line height works, sorta. The problem I had is that it seems to render the first line of text 'in the middle'(vertically) of the specified line height, and I couldn't get it to render it aligned along the bottom of the line-height. I went the padding route. It is not perfect, but works.
Cliff