Skip to content

Div and Span

More Organization!

  • Lesson
  • 1 min read
  • 5 of 6 in this chapter

Div and Span

The div and span tags are often used for organizational purposes, or for styling with CSS. They have no default formatting (no special font size or text decoration), and without CSS, they don't change how the page looks. The only difference between the two is that div is a block element, and span is an inline one. Here's an example of how they may be used:

HTML
<div>
    <h1>Name 1</h1>
    <p>@username1</p>
    <p>This is a short paragraph about the first user</p>
</div>
<div>
    <h1>Name 2</h1>
    <p>@username2</p>
    <p>This is a short paragraph about the second user</p>
</div>

As you can see, these elements don't change much, besides making the code more organized and easier to read, but these tags will be very important when you use CSS later on.