Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

How to align text in a floated DIV

Question posted by: donpro (Guest) on June 27th, 2008 07:19 PM
Hi,

I have the following code snippet:

<div id="header_menuitems">
<a href="home" title="Home page">Home</a|
<a href="aboutus" title="About Us">About Us</a|
<a href="contactus" title="Contact Us">Contact Us</a|
<a href="home" title="Login">Login</a>
</div>


and accompanying CSS code:

#header_menuitems {
float: left;
padding-top: 5px;
padding-right: 10px;
color: white;
font-weight: bold;
text-align: right;
}

My problem is that the links are not aligning to the right of the DIV
(tested in Firefox and IE 7). However, if I comment out the:

float: left;

Then it aligns to the right of the DIV. Is this normal behavior and
if so, is there a work-around?

Thanks,
Don
dorayme's Avatar
dorayme
Guest
n/a Posts
June 27th, 2008
07:19 PM
#2

Re: How to align text in a floated DIV
In article
<f96714b5-4f4a-4434-ac09-82f7fbfbffd9@34g2000hsh.googlegroups.com>,
donpro <donpro-2003@rogers.comwrote:
Quote:
Hi,
>
I have the following code snippet:
>
<div id="header_menuitems">
<a href="home" title="Home page">Home</a|
<a href="aboutus" title="About Us">About Us</a|
<a href="contactus" title="Contact Us">Contact Us</a|
<a href="home" title="Login">Login</a>
</div>
>
>
and accompanying CSS code:
>
#header_menuitems {
float: left;
padding-top: 5px;
padding-right: 10px;
color: white;
font-weight: bold;
text-align: right;
}
>
My problem is that the links are not aligning to the right of the DIV
(tested in Firefox and IE 7).


Yes it is aligning to the right but you cannot see it because a float
shrinks the width to fit the content. To see it, add a generous width
and a *black* border to the div.


Quote:
However, if I comment out the:
>
float: left;
>
Then it aligns to the right of the DIV. Is this normal behavior and
if so, is there a work-around?


You have not quite described what you want worked around. You want the
menu to be on the left of the page generally but right within something
else. See above and supply a url for further information

--
dorayme

 
Not the answer you were looking for? Post your question . . .
190,071 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors