1

I'm trying to make sense of the CSS float property, and I understand the basic motivation of text flowing around a floated image. My question is this: since inline elements flow around floated elements, even if if those inline elements are children of non-floated block-level elements, can we somehow consider the text inside the paragraph element to be inline? I'm trying to form a good mental model of what is happening. Thanks.

mskfisher
  • 3,291
  • 4
  • 35
  • 48
worker1138
  • 2,071
  • 5
  • 29
  • 36

2 Answers2

3

From the CSS spec:

Any text that is directly contained inside a block container element (not inside an inline element) must be treated as an anonymous inline element.

So it's an inline box generated by a block element as opposed to an inline box generated by an inline element. Anonymous only means that it doesn't have an associated inline element.

melhosseiny
  • 9,992
  • 6
  • 31
  • 48
0

<p> is a block element. <p> cannot enclose other block elements. Text inside of <p> is inline by default.

Vin Burgh
  • 1,399
  • 1
  • 8
  • 14
  • I'm sure that block-level elements can enclose other block-level elements...maybe I don't understand what you mean by inline-block? – worker1138 Feb 01 '12 at 22:38
  • Yes, you're right, block elements can enclose other block-level elements. However,

    is an exception to the rule; it's a block element that was never designed nor intended to act as a container for other block elements.

    – Vin Burgh Feb 01 '12 at 22:41
  • Yes, that makes sense, thanks for highlighting that exception, I was not aware of it until now. – worker1138 Feb 01 '12 at 22:42