Codeblooded Saiyan
Codeblooded Saiyan

Reputation: 1497

Difference between text inside the span vs just inside the body

What's the difference between a text inside the span vs not inside the span (just inside the body)

Because technically, they have different width, is it possible to make them the same in width?

The one outside the span has 24 x 17

enter image description here

The one inside the span has 22.22 x 17

enter image description here

I'm also curios why they are different?

Physically, they are the same. What's the right explanation for this?

Upvotes: 1

Views: 445

Answers (1)

Ankur Choudhury
Ankur Choudhury

Reputation: 189

The text inside body are text nodes which represent the whitespace characters between your tags in the DOM (Text Nodes)

So the "text" outside span shows you the width as per your code formatting, spacing or indentation in your code.

Another difference between the two is that parent of text node "text" is diplay block; whereas text inside span has its display as inline.

Upvotes: 3

Related Questions