Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the width of inline elements

Tags:

html

css

xhtml

You can set the width of inline elements like <span>, <em> and <strong>, but you won’t notice any effect until you position them.

a) I thought the width of inline an inline element can’t be set?

b) Assuming width can be set - we won’t notice any effects ( thus the width we specify ) until we position inline element. Position how/where?

c) Why is the width of inline elements apparent only when we “position” them?

like image 500
SourceC Avatar asked Sep 14 '09 18:09

SourceC


2 Answers

There's also the option of display: inline-block, which might give you the best of both worlds.

like image 135
charliepark Avatar answered Oct 08 '22 05:10

charliepark


a) The width of an inline element is ignored

b,c) When you "position" an inline element (I assume that means using position:absolute), you are actually making it a block element, whose width is interpreted by the browser

like image 26
Flavius Stef Avatar answered Oct 08 '22 04:10

Flavius Stef