Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

CSS Equivalent to Valign?



6:38 pm on May 8, 2003 (gmt 0)

I have a div that spans 720px and is 59px high, I have a image that is left aligned and 59x59, I then have a text piece "Website Name" that I want to be set to 9px from the right edge of the image and centered in the div height wise.

In a table I would have just set the v-align, but that does not seem to be working for this.

I am stuck. :) probably need more caffiene.

Can someone point me in the right direction to get this set up the way I want?



7:05 pm on May 8, 2003 (gmt 0)

10+ Year Member

You could set vertical-align: middle; to your div, but read this thread before as it points some issues (others might suggest an easier way):

Vertical-Align: Browser Support? [webmasterworld.com]



7:56 pm on May 8, 2003 (gmt 0)

10+ Year Member

Since you know the height of the div that it will be in (59px), you could probably just wrap the text in another div and use margin to move it down. Here is the code I used to test this thought.

#container {
width: 100%;
height: 59px;
background-color: #CCC;
#text {
margin: 18px 0px 0px 0px;

<div id="container">
<div id="text">
Text here

I got the 18px by doing 59/2 - an estimation of the font size (if it is fixed (px) you can just use that value). So 59/2 - 12 = 17.5, round up to 18. This would really only work for a fixed layout though...


12:07 pm on May 9, 2003 (gmt 0)

10+ Year Member

<style type="text/css">
#div1 {border:1px solid #000; width:720px;}
#img1 {margin-right:9px; vertical-align:middle;}

<div id="div1">
<img id="img1" alt="" src="anImage.gif" height="59" width="59" /><span>Website Name</span>


Featured Threads

Hot Threads This Week

Hot Threads This Month