Lesson 8 of 15

Divs & Spans

Divs and Spans

<div> and <span> are generic container elements with no built-in meaning.

<div> is a block-level element — it takes up the full width:

<div class="card">
  <p>Content inside a div</p>
</div>

<span> is an inline element — it sits within text:

<p>The sky is <span style="color: blue;">blue</span> today.</p>

Use class and id attributes to target them with CSS:

<div id="header" class="container nav-bar">
  <span class="logo">MyBrand</span>
</div>

Your Task

Create a <div> with a class attribute containing another <div>, and use a <span> to style part of a paragraph.

HTML preview loading...
Loading...
Click "Run" to execute your code.