div
-
Hai I am using div.Inside the div i wrote some content. for that i set width auto, browser take it with as 100%.why it is taking like that. i want the width is equal to my content. example
Hai
in css div { width:auto; } If i gave like this it should measure only the word know.but it measure the whole line. Can give the solution . why it is happen like this. Thanks in advance
-
Hai I am using div.Inside the div i wrote some content. for that i set width auto, browser take it with as 100%.why it is taking like that. i want the width is equal to my content. example
Hai
in css div { width:auto; } If i gave like this it should measure only the word know.but it measure the whole line. Can give the solution . why it is happen like this. Thanks in advance
You are using a block-level element (div) which will always attempt to take up "the entire line" as opposed to flow-level elements (
u
,img
,span
etc.) which take up just the space of their contents. You should not be settingwidth: auto
often as it is the default. Only if you are overriding inherited properties will you set it. I don't know what you are trying to do but this may be more appropriate:<span>
<u>Hai</u>
</span>span
is a flow-level generic element whilediv
is a block-level generic element.cheers, Paul M. Watson.