/
Just use div elements - don't use span elements.

Just use div elements - don't use span elements.

Both of these elements are extensively used in modern HTML together with CSS. The only real difference is that:

  • span elements have the built in display : inline

  • div elements have the built in display : block

If you change the display property of a span to be block you can make it behave like a div. Likewise if you change the display property of a div to be inline-block then you can make it behave like a span.

We do exactly that experiment here.

So in the interests of simplicity and avoiding features it makes sense to just use <div> tags and combine it with CSS. There is less abstraction which means one needs to think through the problems more thoroughly.

 

Related content

Understand display : inline versus block
Understand display : inline versus block
More like this
Lists
More like this
How can we find simplicity in CSS?
How can we find simplicity in CSS?
More like this
How to use the class attribute of HTML elements.
How to use the class attribute of HTML elements.
Read with this
HTML Structure
HTML Structure
More like this
Describe categories with classes rather styling specific elements
Describe categories with classes rather styling specific elements
Read with this