Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CSS/DIV equivalent of ALIGN=BASELINE

0 views
Skip to first unread message

Steve Swift

unread,
Jul 16, 2008, 3:24:45 AM7/16/08
to
I'm still trying to learn CSS and the use of DIV, and a few examples
will get me started.

My challenge at the moment is to place some text to the right of a
header (a sort of footnote) and to have the baselines of the text
aligned. I can do this with a table:

<TABLE><TR VALIGN=BASELINE><TD><H2>Header</H2><TD>Comment</TABLE>

But my feeble attempt with DIVs fails:

<DIV STYLE="float:left;vertical-align:baseline"><H2>Header 2</H2></DIV>
<DIV STYLE="float:left;vertical-align:bottom">text</DIV>

Am I missing something obvious, or is this harder than it looks?

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk

Ben C

unread,
Jul 16, 2008, 3:56:20 AM7/16/08
to
On 2008-07-16, Steve Swift <Steve....@gmail.com> wrote:
> I'm still trying to learn CSS and the use of DIV, and a few examples
> will get me started.
>
> My challenge at the moment is to place some text to the right of a
> header (a sort of footnote) and to have the baselines of the text
> aligned. I can do this with a table:
>
><TABLE><TR VALIGN=BASELINE><TD><H2>Header</H2><TD>Comment</TABLE>
>
> But my feeble attempt with DIVs fails:
>
><DIV STYLE="float:left;vertical-align:baseline"><H2>Header 2</H2></DIV>
><DIV STYLE="float:left;vertical-align:bottom">text</DIV>
>
> Am I missing something obvious, or is this harder than it looks?

No, and it is harder than it looks :)

Vertical-align only applies to things that are display: inline or
table-cell, and it isn't inherited, so it does nothing on your divs.

Will this do:

h2 { display: inline }

...

<h2>Header 2</h2> text

dorayme

unread,
Jul 16, 2008, 4:10:16 AM7/16/08
to
In article <487e...@news.greennet.net>,
Steve Swift <Steve....@gmail.com> wrote:

> I'm still trying to learn CSS and the use of DIV, and a few examples
> will get me started.
>
> My challenge at the moment is to place some text to the right of a
> header (a sort of footnote) and to have the baselines of the text
> aligned. I can do this with a table:
>
> <TABLE><TR VALIGN=BASELINE><TD><H2>Header</H2><TD>Comment</TABLE>
>

Well, that does not align the baselines.



> But my feeble attempt with DIVs fails:
>
> <DIV STYLE="float:left;vertical-align:baseline"><H2>Header 2</H2></DIV>
> <DIV STYLE="float:left;vertical-align:bottom">text</DIV>
>
> Am I missing something obvious, or is this harder than it looks?

Is this what you want:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css" media="screen">
h2 {font-size: 200%;}
span {position:relative; font-size: 50%;}
</style>
</head>
<body>
<h2>Header <span>Comment</span></h2>
</body>
</html>

--
dorayme

dorayme

unread,
Jul 16, 2008, 4:15:46 AM7/16/08
to
In article
<doraymeRidThis-AC4...@news-vip.optusnet.com.au>,
dorayme <dorayme...@optusnet.com.au> wrote:

> span {position:relative; font-size: 50%;}

should be

span {font-size: 50%;}

I meant to delete position: relative;, it was from an earlier fiddling.

--
dorayme

dorayme

unread,
Jul 16, 2008, 4:22:03 AM7/16/08
to

> In article <487e...@news.greennet.net>,
> Steve Swift <Steve....@gmail.com> wrote:
>
> > I'm still trying to learn CSS and the use of DIV, and a few examples
> > will get me started.
> >
> > My challenge at the moment is to place some text to the right of a
> > header (a sort of footnote) and to have the baselines of the text
> > aligned. I can do this with a table:

> Is this what you want:
>

Sorry to come in again, but a further thought, to make the comment plain
text, not bold:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css" media="screen">
h2 {font-size: 200%;}

span {font-size: 50%;font-weight: normal;}

Steve Swift

unread,
Jul 17, 2008, 1:48:59 AM7/17/08
to
Ben C wrote:
> Will this do:
>
> h2 { display: inline }
> ...
> <h2>Header 2</h2> text

I wouldn't want to change all H2 instances, but I can certainly use this
approach. Thanks for showing me something I hadn't come across before.

One of my colleagues at work suggested this:

<h2>Part 2 <span style="font-size:small;font-weight:normal">(Experts
Only)</span></h2>

Which is perfect for my occasional use.

Steve Swift

unread,
Jul 17, 2008, 1:51:17 AM7/17/08
to
dorayme wrote:
> Sorry to come in again, but a further thought, to make the comment plain
> text, not bold:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
> <html>
> <head>
> <style type="text/css" media="screen">
> h2 {font-size: 200%;}
> span {font-size: 50%;font-weight: normal;}
> </style>
> </head>
> <body>
> <h2>Header <span>Comment</span></h2>
> </body>
> </html>

That's almost exactly what a colleague at work suggested (see my post
above). Thanks!

I've now splashed out on a book to help me with CSS, so maybe you won't
see me here again in the near future.

dorayme

unread,
Jul 17, 2008, 2:38:32 AM7/17/08
to
In article <48802a1e$1...@news.greennet.net>,
Steve Swift <Steve....@gmail.com> wrote:

> dorayme wrote:
> > Sorry to come in again, but a further thought, to make the comment plain
> > text, not bold:
> >
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

...


>
> That's almost exactly what a colleague at work suggested (see my post
> above). Thanks!
>
> I've now splashed out on a book to help me with CSS, so maybe you won't
> see me here again in the near future.

That's what I call optimism! Good luck.

--
dorayme

Bergamot

unread,
Jul 17, 2008, 5:38:23 PM7/17/08
to

Steve Swift wrote:
>
> <h2>Part 2 <span style="font-size:small;font-weight:normal">(Experts
> Only)</span></h2>

<h2>Part 2 <small>(Experts Only)</small></h2>

Inline styles are a PITA so put the font settings in your CSS, i.e.

h2 small {font-weight:normal}

--
Berg

0 new messages