CSS Display Options

The display property sets an elements inner and outer display types. Inner refers to any child elements inside the element, and outer refers to the element itself, more specifically its participation in flow layout

What is display?

Display is something we can use to specify how html elements take up space in our website layout (also known as flow). By default, elements are either Block or Inline. Block elements create a newline above and below its surrounding elements, and they take up the entire width of the page. Inline elements only take up as much space as is needed (eg the length of the text), and they do not create newlines before or after them (so two inline elements could display side by side if theyre small enough, but for two block elements this would not be possible, unless we change their display property!)

also, width and height do not apply to inline elements

Outside

These keywords specify the element's outer display type, which is essentially its role in flow layout

Inside

These keywords specify the elements inner display type, which defines the type of formatting context that its content (its children) will be laid out in (assuming it is a non-replaced element (dont know what that means)). When one of these keywords is used by itself as a single value (ex. display: flex as opposed to display: block flex), the element's outer display type defaults to block (with the exception of ruby, which defaults to inline).

Name Inside/Outside Line Breaks?
block Outside Yes
inline Outside No
inline-block Outside No
flex Inside Yes

Credit: I got my information and learned from mozilla docs and from this 4 minute youtube video explaining display basics

Lucca Chantre

luccachantre@gmail.com

Linkedin Github