HTML & CSS Masterclass Tutorial

Comprehensive guide to modern HTML and CSS development.

Layout Fundamentals

Layout Fundamentals: Display property

The display property determines how an element behaves in the document flow.

  • Block (display: block): Takes up the full width available, forcing a line break before and after it. Elements like <div>, <h1>, and <p> are block-level by default.
  • Inline (display: inline): Takes up only as much width as necessary. Does not force line breaks. You cannot set width or height on inline elements! Elements like <span> and <a> are inline by default.
  • Inline-Block (display: inline-block): Sits inline with text, but allows you to set width, height, margin, and padding!
  • None (display: none): Completely removes the element from the document.

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics