HTML Block and Inline Elements

Each HTML element has a default display value, based on type of element.

There are two display values:

  1. Block
  2. Inline.

    Inline-level elements:

    1. Only take up as much width as necessary.
    2. Do not create a new block formatting context.
    3. Do not start on a new line and do not push down any elements that come after it.
    4. Do not have a height, width, and padding properties.
    5. Can contain only other inline elements and text.
    6. Examples of inline-level elements include: <a>, <img>, <span>, <em>, <strong>, <br>, <button>, <input>, <label>, <select>, <textarea>.

      Below is the table summarise what each of those element does.

      Inline-level tagsDescription
      <a>Defines a hyperlink.
      <img>Defines an image.
      <span>Defines a small section of text.
      <em>Defines emphasized text.
      <strong>Defines important text.
      <br>Inserts a line break.
      <button>Defines a clickable button.
      <input>Defines an input control.
      <label>Defines a label for an input element.
      <select>Defines a drop-down list.
      <option>Defines an option in a drop-down list.
      <textarea>Defines a multiline input control.

      Note: some tags may behave differently based on the context.

      .<span> tag is an inline-level element that is used to group elements for styling purposes, and it doesn’t provide any semantic meaning to the content it contains.

      Block-level elements:

      1. Take up the full width of their parent container.
      2. Create a new block formatting context.
      3. Start  with new line and goes down any elements that come after it.
      4. Have a height, width and padding properties.
      5. Can also contain other block and inline elements.
      6. Examples of block-level elements include: <div>, <h1>, <p>, <ul>, <ol>, <form>, <table>, <header>, <footer>, <main>.
      Block-level tagsDescription
      <div>Defines a section of the document and can be used as a container for other elements.
      <h1> – <h6>Defines headings. <h1> is the most important heading and <h6> is the least important.
      <p>Defines a paragraph.
      <ul>Defines an unordered list.
      <ol>Defines an ordered list.
      <li>Defines a list item.
      <dl>Defines a description list.
      <dt>Defines a term in a description list.
      <dd>Defines a description of a term in a description list.
      <form>Defines a form for user input.
      <table>Defines a table.
      <header>Defines a header section.
      <footer>Defines a footer section.
      <main>Defines the main content of a document.

      Leave a Reply

      Your email address will not be published. Required fields are marked *