WDD 130: Web Fundamentals

W02 Learning Activity: HTML Block and Inline Elements

Overview

An HTML element is, by default, either a block-level or an inline element. Block elements occupy the full width of their container and start on new lines. Inline elements only occupy the space needed for the content and do not start on a new line.

Preparation Material

Carefully ponder, note, and reference the materials provided and concepts presented in the learning modules.

Block-level Elements

Block-level elements start on a new line on a page and take up the full width of their container. This means the element container stretches out to the left and right as far as it can. Some common block-level elements are: <p> and <div> and all the semantic containers like <header>, <footer>, <main>, <nav>, and <section>.

Inline Elements

Inline elements do not start on a new line and only take up the space bounded by the tags defining the element. Some common inline elements are: <span>, <a>, <img>, <button>, and <input>.

Video Demonstration: ▶️ Block versus Inline Elements[ 4:36 minutes, 📄 Transcript ]

Activity Instructions

Answer the following questions about HTML elements.

  1. Which of the following HTML elements are inline elements by default?
    <header> <div> <span> <table> <form> <a> <label> <button> <input> <p> <aside> <cite>
    Check Your Understanding

    <span> <a> <label> <button> <input> <cite>
    The other elements that are listed are block-level elements by default.

    How are you supposed to figure out which is which? You can try them out on your page. And you should also learn to get information using reliable sources. For example, you can use the HTML Reference to look up an element to verify if the element is block or inline.

  2. Open the page named block-vs-inline.html in the week02 subfolder of your wdd130 folder.
  3. Review the HTML structure.
  4. To help you complete the exercise, render the page in Live/Five Server by right mouse clicking on the file name and selecting "Open with Live/Five Server".

    The page has been styled with CSS to help illustrate the differences between block and inline elements.

  5. Complete the tasks as given.
  6. Note that the inline elements <span> <img> <a> and <button> are only as big as the content within them.

Optional Resources