worker1138
worker1138

Reputation: 2101

Is the text inside the <p> element considered an inline element?

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.

Upvotes: 2

Views: 387

Answers (2)

melhosseiny
melhosseiny

Reputation: 10144

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.

Upvotes: 5

Vin Burgh
Vin Burgh

Reputation: 1419

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

Upvotes: 0

Related Questions