When it comes to styling text or creating block areas, the choice between inline and block display is straightforward. Use inline for short spans of text, such as a few words, and use block for rectangular areas with width and height dimensions.
Inline-block, on the other hand, is commonly used for images. It allows small blocks to flow in a left-to-right, top-to-bottom manner like regular text while still maintaining their block-like properties.
It's important to note that in most cases, specifying the display property is unnecessary. Instead, you can simply utilize appropriate HTML elements with classes, like <strong>
or <em>
for inline styling, and <div>
or <p>
for block elements. The main use of explicitly setting the display property typically arises when hiding elements in Javascript, where you may need to revert them back to their default display attribute.