what is display block in css

what is display block in css

1 year ago 74
Nature

The display property in CSS determines how an element is displayed on a web page. It specifies the type of rendering box of an element, which can be either a block or an inline box, and the layout used for its children, such as flow layout, grid, or flex.

  • A block-level element always starts on a new line and takes up the full width available. It generates a block box, which generates line breaks both before and after the element when in the normal flow. Examples of block-level elements include <div>, <section>, and <p> .
  • An inline-level element does not start on a new line and only takes up as much width as necessary. It generates an inline box, which behaves much like a text character in a sentence. Examples of inline-level elements include <span>, <a>, and <img> .
  • An inline-block element is a hybrid of block and inline elements. It allows you to set a width and height on the element, and the top and bottom margins/paddings are respected. It does not add a line-break after the element, so it can sit next to other elements.

The display property can take many different values, such as block, inline, inline-block, flex, grid, and more, which all influence the layout and presentation of an element on a web page.

Read Entire Article