Why some elements don't have height and width?


#1

Question

Why do we need to set height and width, and why some elements don’t have it?

Answer

It is not always necessary to set a height and width. Elements by default are block elements and will have the same width as the container, and their height will vary depending on their content. The element’s measurements will be decided by what purpose we want it to have, just like news paper’s editors will arrange the columns, sometimes we will want to have an image that will only cover half of the screen, or even less. That is when we could use height and/or width measurements.


#2

#3