HighDots Forums  

newbie: header spanning two columns with left- and right-alignment

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss newbie: header spanning two columns with left- and right-alignment in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
ironcorona
 
Posts: n/a

Default Re: newbie: header spanning two columns with left- and right-alignment - 05-17-2006 , 11:19 PM






jkn wrote:
Quote:
Hi Els

When you float something to the right, it does not magically go up one
line. To have it on the same line as other text, place the float
*before* the other text.

Hey, that works! on all the browsers I tried - thanks!

I'd like to understand this a bit more though - what is the 'marker'
that means that my original text had a line break (or equivalent) after
the left aligned words? You say 'it doesn't go up one line' - what I
don't understand is why it starts off one line below. From what I
understand of this area (could well be wrong!), the behaviour seems as
though my two bits of text were separate 'display: block' sections.
'How come' - is what I'm asking, I think.
Could this behaviour have something to do with the fact that you've
turned the <span> into a block level element?

<h*> elements are only suppose to contain inline elements:

http://www.w3.org/TR/html4/struct/global.html#edef-H1

so I think maybe Firefox is assuming a missing </h1> tag and then
putting the span on the next line (because <h1> is block).

if there was better support for display:inline-block; this would all be
a lot easier.

To get the effect something like this would work:


..left_aligned {display:inline; float:left;}
..right_aligned {display:inline; float:right;}


<h1 class="normal">left hand text</h1>
<h1 class="right_aligned">right hand text</h1>

Although this isn't going to work out very well for people with text
browsers or people who have their user-stylesheet overriding the author's.

Ho-hum!

--
Brian O'Connor (ironcorona)


Reply With Quote
  #12  
Old   
ironcorona
 
Posts: n/a

Default Re: newbie: header spanning two columns with left- and right-alignment - 05-17-2006 , 11:21 PM






ironcorona wrote:

Quote:
.left_aligned {display:inline; float:left;}
.right_aligned {display:inline; float:right;}


h1 class="normal">left hand text</h1
h1 class="right_aligned">right hand text</h1
Sorry. Clearly I meant:

..left_aligned {display:inline; float:left;}
..right_aligned {display:inline; float:right;}

<h1 class="left_aligned">left hand text</h1>
<h1 class="right_aligned">right hand text</h1>


--
Brian O'Connor (ironcorona)


Reply With Quote
  #13  
Old   
Els
 
Posts: n/a

Default Re: newbie: header spanning two columns with left- and right-alignment - 05-18-2006 , 01:06 AM



ironcorona wrote:
Quote:
jkn wrote:
Hi Els

When you float something to the right, it does not magically go up one
line. To have it on the same line as other text, place the float
*before* the other text.

Hey, that works! on all the browsers I tried - thanks!

I'd like to understand this a bit more though - what is the 'marker'
that means that my original text had a line break (or equivalent) after
the left aligned words? You say 'it doesn't go up one line' - what I
don't understand is why it starts off one line below. From what I
understand of this area (could well be wrong!), the behaviour seems as
though my two bits of text were separate 'display: block' sections.
'How come' - is what I'm asking, I think.
Well, according to this page on the specs:
http://www.w3.org/TR/CSS21/visuren.html#float-position
IE and Firefox are doing it wrong.

Quote:
Could this behaviour have something to do with the fact that you've
turned the <span> into a block level element?

h*> elements are only suppose to contain inline elements:

http://www.w3.org/TR/html4/struct/global.html#edef-H1

so I think maybe Firefox is assuming a missing </h1> tag and then
putting the span on the next line (because <h1> is block).
No, in HTML, <span> is inline, so there is no </h1> missing.

Quote:
if there was better support for display:inline-block; this would all be
a lot easier.
Wouldn't help in this particular case though.

Quote:
To get the effect something like this would work:

.left_aligned {display:inline; float:left;}
.right_aligned {display:inline; float:right;}

h1 class="left_aligned">left hand text</h1
(the above line edited as per your next post ;-) )
h1 class="right_aligned">right hand text</h1
This will work, because the right-floated text is not part of the
first <h1> now. The display:inline is entirely superfluous there btw;
as soon as you float an element, it becomes block level.
(see the same url as mentioned above)

Anyway, as to why Firefox and IE don't float the <span> to the right
of the rest of the <h1>: I've just tested it with borders on, which
shows that the <h1> is just taking up full width, so I assume Firefox
and IE take the floated bit as "moved out" from its original place.

Not correct according to the CSS2.1 specs afaics, and it seems only
Opera gets it right. (that is, of the 3 browsers I tested it in)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/

Now playing: Terence Trent d'Arby - Dance Little Sister


Reply With Quote
  #14  
Old   
Barbara de Zoete
 
Posts: n/a

Default Re: newbie: header spanning two columns with left- and right-alignment - 05-18-2006 , 01:27 AM



On Wed, 17 May 2006 21:15:06 +0200, Els <els.aNOSPAM (AT) tiscali (DOT) nl> wrote:

Quote:
Barbara de Zoete wrote:

#Header span {display: block; float: right;}

div id="Header"
My Site Name<span>My Right-aligned text</span
/div

With FF I'm seeing what I was seeing on
my page - the 'right aligned text' is outside the red border, on the
line below.

So am I
encountering a bug in Firefox?

Could be. I don't know actually. And I don't know my way around bugs and
bug reports either. Maybe another poster.

Somebody?

When you float something to the right, it does not magically go up one
line. To have it on the same line as other text, place the float
*before* the other text.
<drums>
Els to the rescue!
</drums>

You're right of course. I don't know why I missed that. Thanks Els.



--
______PretLetters:

Reply With Quote
  #15  
Old   
Els
 
Posts: n/a

Default Re: newbie: header spanning two columns with left- and right-alignment - 05-18-2006 , 01:47 AM



Barbara de Zoete wrote:

Quote:
On Wed, 17 May 2006 21:15:06 +0200, Els <els.aNOSPAM (AT) tiscali (DOT) nl> wrote:

Barbara de Zoete wrote:

#Header span {display: block; float: right;}

div id="Header"
My Site Name<span>My Right-aligned text</span
/div

With FF I'm seeing what I was seeing on
my page - the 'right aligned text' is outside the red border, on the
line below.

So am I
encountering a bug in Firefox?

Could be. I don't know actually. And I don't know my way around bugs and
bug reports either. Maybe another poster.

Somebody?

When you float something to the right, it does not magically go up one
line. To have it on the same line as other text, place the float
*before* the other text.

drums
Els to the rescue!
/drums

You're right of course. I don't know why I missed that. Thanks Els.
Well, it was apparently based on past experience, not on the specs, as
you'll see in my other post (reply to ironcorona)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/

Now playing: 2 Unlimited - Sensuality


Reply With Quote
  #16  
Old   
ironcorona
 
Posts: n/a

Default Re: newbie: header spanning two columns with left- and right-alignment - 05-18-2006 , 01:53 AM



Els wrote:

Quote:
Well, according to this page on the specs:
http://www.w3.org/TR/CSS21/visuren.html#float-position
IE and Firefox are doing it wrong.

Could this behaviour have something to do with the fact that you've
turned the <span> into a block level element?

h*> elements are only suppose to contain inline elements:

http://www.w3.org/TR/html4/struct/global.html#edef-H1

so I think maybe Firefox is assuming a missing </h1> tag and then
putting the span on the next line (because <h1> is block).

No, in HTML, <span> is inline, so there is no </h1> missing.
But didn't you just set #Header span {display: block; float: right;} or
am I not keeping up?

Quote:
To get the effect something like this would work:

.left_aligned {display:inline; float:left;}
.right_aligned {display:inline; float:right;}

h1 class="left_aligned">left hand text</h1
(the above line edited as per your next post ;-) )
h1 class="right_aligned">right hand text</h1

This will work, because the right-floated text is not part of the
first <h1> now. The display:inline is entirely superfluous there btw;
as soon as you float an element, it becomes block level.
(see the same url as mentioned above)
Oh, you're right of course. As you saw from my mess up I was trying
another solution but changed it. And left some of the wrong stuff.

[snip]

Quote:
Not correct according to the CSS2.1 specs afaics, and it seems only
Opera gets it right. (that is, of the 3 browsers I tested it in)
Damned Opera and their sticking to the standard

--
Brian O'Connor (ironcorona)


Reply With Quote
  #17  
Old   
Els
 
Posts: n/a

Default Re: newbie: header spanning two columns with left- and right-alignment - 05-18-2006 , 02:06 AM



ironcorona wrote:
Quote:
Els wrote:

so I think maybe Firefox is assuming a missing </h1> tag and then
putting the span on the next line (because <h1> is block).

No, in HTML, <span> is inline, so there is no </h1> missing.

But didn't you just set #Header span {display: block; float: right;} or
am I not keeping up?
That is CSS. You assign display:block to an inline element. A browser
will only assume closing tags missing if the HTML is wrong.
HTML rule: inline elements (and a couple of block elements like h1 and
p) can't hold block elements.
CSS practice: assign inline or block to any block or inline element
and get away with it ;-)

[snip]

Quote:
Not correct according to the CSS2.1 specs afaics, and it seems only
Opera gets it right. (that is, of the 3 browsers I tested it in)

Damned Opera and their sticking to the standard
<g>

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/

Now playing: Soul Asylum - April Fool


Reply With Quote
  #18  
Old   
Barbara de Zoete
 
Posts: n/a

Default Re: newbie: header spanning two columns with left- and right-alignment - 05-18-2006 , 02:10 AM



On Thu, 18 May 2006 08:47:16 +0200, Els <els.aNOSPAM (AT) tiscali (DOT) nl> wrote:

[ float:right; Moves outside a parent block level element in FF ]

Quote:
drums
Els to the rescue!
/drums

You're right of course. I don't know why I missed that. Thanks Els.

Well, it was apparently based on past experience, not on the specs, as
you'll see in my other post (reply to ironcorona)
I remember that too, but only now that you've mentioned it. I remember
struggling with it and finally just letting the float be the first thing
inside its parent. Not really understanding why it worked one way and not
the other, because it should have no effect really, being first or last
thing inside the parent if you're floated.


--
______PretLetters:

Reply With Quote
  #19  
Old   
ironcorona
 
Posts: n/a

Default Re: newbie: header spanning two columns with left- and right-alignment - 05-18-2006 , 02:20 AM



Els wrote:

Quote:
so I think maybe Firefox is assuming a missing </h1> tag and then
putting the span on the next line (because <h1> is block).
No, in HTML, <span> is inline, so there is no </h1> missing.
But didn't you just set #Header span {display: block; float: right;} or
am I not keeping up?

That is CSS. You assign display:block to an inline element. A browser
will only assume closing tags missing if the HTML is wrong.
HTML rule: inline elements (and a couple of block elements like h1 and
p) can't hold block elements.
CSS practice: assign inline or block to any block or inline element
and get away with it ;-)
Okay, I think I'm with you now. I assumed that if you had something like

<p><span></span></p>

and you set

span {display:block;}

that the browser would treat it exactly as if it were something like

<p><div></div></p>

and thus illegal because <p> contains a block element.

But that's not how it works?


--
Brian O'Connor (ironcorona)


Reply With Quote
  #20  
Old   
Els
 
Posts: n/a

Default Re: newbie: header spanning two columns with left- and right-alignment - 05-18-2006 , 02:29 AM



ironcorona wrote:

Quote:
HTML rule: inline elements (and a couple of block elements like h1 and
p) can't hold block elements.
CSS practice: assign inline or block to any block or inline element
and get away with it ;-)

Okay, I think I'm with you now. I assumed that if you had something like

p><span></span></p

and you set

span {display:block;}

that the browser would treat it exactly as if it were something like

p><div></div></p

and thus illegal because <p> contains a block element.

But that's not how it works?
Indeed :-)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/

Now playing: Yes - Yours Is No Disgrace


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.