Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

label width problem

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
hello,

Why can I not apply a width to a label element unless I float it?

thanks,

1DMF.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
I believe it's because a label in an inline element. If you make it display:block, you can set a width to it.

[small]"Mom........MEATLOAF!!!! F***!!!!"[/small]
<.
 
I just tested what I said, in IE, width can be set initially, but in FF, you do have to make display:block on the label in order to set a width.




[small]"Mom........MEATLOAF!!!! F***!!!!"[/small]
<.
 
block is no good, because then it's the same as putting <br /> on the end and so it is no longer a label for the field as it is now on a new line, so float it is :)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
oh and isn't input an inline element yet you can change the width of them!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Hmm..

Yeah you're right. Let me reword that.

In FF, inline elements only take up the amount of space that it's content takes up.

When you specify the width of an input, the input object takes up all the space inside the width you specify.

A label may only have one word in it, in this case the width of the label will only take up the amount needed to contain the one word.

I do and don't know what I'm talking about :)



[small]"Mom........MEATLOAF!!!! F***!!!!"[/small]
<.
 
I do and don't know what I'm talking about :)
I know that feeling - lol :)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top