The Div and Span Tag In CSS
Lessons Covered

The div and span tag is used frequently and you will be using quite alot of it when you start creating your own websites.



The Div Tag

The div tag is often times used for divisions of a web page. You can use div tags when you want to style a group of elements.

As an example, to demonstrate the use of div tag:

style.css

The stylesheet is defined with the class we will use.
.edit
{
color: purple;
text-decoration: underline;
}


webpage.html

Using the div tag to apply the style to a group of elements:
<div class="edit">
<h4> This is a heading </h4>
<h5> This is another heading </h5>
<p> This is a pararaph </p>
</div>

arrow  Click to see result


The Span Tag

The span tag unlike the div is used to style things in-line rather than a group of elements.

webpage.html

Using the span:
<h4> This is a <span class="edit">heading </span></h4>
<p> This is a <span class="edit">paragraph</span></p>


    Previous Lesson Previous Lesson - ID & Class                                         Next Lesson - Text Next Lesson