473,800 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CSS/DIV equivalent of ALIGN=BASELINE

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:le ft;vertical-align:baseline" ><H2>Header 2</H2></DIV>
<DIV STYLE="float:le ft;vertical-align:bottom">t ext</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
Jul 16 '08 #1
8 4285
On 2008-07-16, Steve Swift <St***********@ gmail.comwrote:
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:le ft;vertical-align:baseline" ><H2>Header 2</H2></DIV>
<DIV STYLE="float:le ft;vertical-align:bottom">t ext</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</h2text
Jul 16 '08 #2
In article <48******@news. greennet.net>,
Steve Swift <St***********@ gmail.comwrote:
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:le ft;vertical-align:baseline" ><H2>Header 2</H2></DIV>
<DIV STYLE="float:le ft;vertical-align:bottom">t ext</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:relat ive; font-size: 50%;}
</style>
</head>
<body>
<h2>Header <span>Comment </span></h2>
</body>
</html>

--
dorayme
Jul 16 '08 #3
In article
<do************ *************** *******@news-vip.optusnet.co m.au>,
dorayme <do************ @optusnet.com.a uwrote:
span {position:relat ive; font-size: 50%;}
should be

span {font-size: 50%;}

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

--
dorayme
Jul 16 '08 #4
In article
<do************ *************** *******@news-vip.optusnet.co m.au>,
dorayme <do************ @optusnet.com.a uwrote:
In article <48******@news. greennet.net>,
Steve Swift <St***********@ gmail.comwrote:
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;}
</style>
</head>
<body>
<h2>Header <span>Comment </span></h2>
</body>
</html>

--
dorayme
Jul 16 '08 #5
Ben C wrote:
Will this do:

h2 { display: inline }
...
<h2>Header 2</h2text
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
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Jul 17 '08 #6
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.

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
Jul 17 '08 #7
In article <48********@new s.greennet.net> ,
Steve Swift <St***********@ gmail.comwrote:
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
Jul 17 '08 #8

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

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

h2 small {font-weight:normal}

--
Berg
Jul 17 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2081
by: Tipwinners | last post by:
This is a multi-part message in MIME format ---=_AZROORDVTILVT.01AA02E60255CJO.02940930 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit This is an HTML message. ---=_AZROORDVTILVT.01AA02E60255CJO.02940930
3
4070
by: ZJT | last post by:
What are the ways and corresponding tools to transform a docbook document to a pdf document? Thanks a lot!
2
6181
by: Felipe Gasper | last post by:
I'm trying to make some "sub-cells" in an HTML table and to control their positioning and content presentation via CSS. In the table at the following URL: https://fshn3152.foods.uiuc.edu/~fgasper/erf.html what I'm immediately trying to do is vertically position the text and checkboxes in all four "Statement Date" sub-cells (created with <span> elements).
2
2584
by: Arne | last post by:
I have problems aligning my left menu with the valign=top: http://test.unitedhardware.com/valign.html It happens a lot when the the middle pane is very complicated with a lot of nested tables. What can I do?
3
2696
by: tshad | last post by:
I have the following: <tr valign="baseline"> <td align="center" width="103" colspan=2 nowrap> <asp:Button ID="ViewPositions" runat="server" Text="View Positions" OnClick="ViewPositions_Click" /> <asp:LinkButton text="Advanced" onClick="Advanced_Click" runat="server"/> </td> </tr>
5
5363
by: Christophe | last post by:
Hello, I try to align the baseline of my title with a white line using CSS. The code does work with Safari Mac, Explorer Mac and PC, Firefox PC. But on Firefox 1.5 Mac and Opera 6.03, the text shifts from the line. I don't understand where these pixels come from (all units are in pixels): <div style="color: #ffffff; font-size: 22px; font-weight: bold; position: absolute; top: 188px; z-index: default;...
3
2397
by: sysguy | last post by:
Hello, I have a table with each <td> has four links in it. There are five cells(i.e <td>) like this and requirement is to align them horizontally on a tabbed panel menu bar. The issue is first two cells align just fine, but later three do not align and show one or two level down. I have checked valign table properties, removed all margins and padding but still no luck. Below is the complete html code. Pleaes view this html output...
8
2820
by: Dave Rado | last post by:
Hi See my mock-up at http://tinyurl.com/35tv29. The three icons are supposed to be vertically aligned on their bottoms (using "vertical- align: bottom"), but they aren't, they're vertically aligned on their tops. Is there any way to align them vertically on their bottoms (or middle for that matter) short of resorting to using a table (where "vertical-align: bottom" does work)? Dave
40
5507
by: maya | last post by:
hi, how do I get text to vertical-align inside a div? http://www.mayacove.com/misc/home.html vertical-align should work, according to this: http://htmlhelp.com/reference/css/text/vertical-align.html
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10251
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.