In how many ways you can display HTML elements?

In how many ways you can display HTML elements?

1 Like
  1. inline: Using this we can display any block-level element as an inline element. The height and width attribute values of the element will not affect.
  2. block: using this, we can display any inline element as a block-level element.
  3. inline-block: This property is similar to inline, except by using the display as inline-block, we can actually format the element using height and width values.
  4. flex: It displays the container and element as a flexible structure. It follows flexbox property.
  5. inline-flex: It displays the flex container as an inline element while its content follows the flexbox properties.
  6. grid: It displays the HTML elements as a grid container.
  7. none: Using this property we can hide the HTML element.

Below are some of the display types which are rarely used:

  1. table
  2. inline-table
  3. table-cell
  4. table-column
  5. table-row
  6. inline-grid
  7. list-item
  8. inherit
  9. initial
  10. table-caption
1 Like

display: block : Elements with a display type of block are commonly called block-level elements and always start on a new line. They also take up the full width that they can (the equivalent of width: 100% )

display: inline : The inline display type does not create a new line, and only takes up as much width as it needs.

display: none : display type of none makes it disappear completely from the page. No space is left for it, and other elements are positioned as if it were not there.

display-inside

These keywords specify the element’s inner display type, which defines the type of formatting context that its contents are laid out in (assuming it is a non-replaced element):

flow

The element lays out its contents using flow layout (block-and-inline layout).

If its outer display type is inline or run-in, and it is participating in a block or inline formatting context, then it generates an inline box. Otherwise it generates a block container box.

Depending on the value of other properties (such as position ,float or overflow and whether it is itself participating in a block or inline formatting context, it either establishes a new block formatting context (BFC) for its contents or integrates its contents into its parent formatting context.

flow-root

The element generates a block element box that establishes a new block formatting context defining where the formatting root lies.

table

These elements behave like HTML < table > elements. It defines a block-level box.

flex

The element behaves like a block element and lays out its content according to the flexbox model

grid

The element behaves like a block element and lays out its content according to the grid model

ruby

The element behaves like an inline element and lays out its content according to the ruby form

1 Like