Div === Span 🤯

In CSS div is equal to span. Yes, you heard that right!

--

Edit:

By Default, the display property of div and span is inline not block and inline. The rest of the article is telling about the same thing. So skip this article and try to read another interesting article.

— Sorry to waste your precious time —

You might know, a div is a block-level element and the span is an inline-block level element. And you might know the difference between display:block and display:inline.

Why div is equal to span?

When you inspect the div it shows display:block

A div is a block-level element and span is an inline-block level element, then why is it equal.

div and span both are inline-block element

Have ever wonder why the browser shows the user agent stylesheet in the styles tab.

These styles are provided by the browser.

When you reset the display using display:initial , you will find the display default value for div

Please check out the first comment, which is far far better than this post itself. Also, it contains excellent information.

Happy reading ❤️.

More content at plainenglish.io

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Naveen DA
Naveen DA

Responses (13)

Write a response