div
In this module we will do the following:
Discuss div tag.
A few notes on divs. Reviewing ul.
Create div-one and discuss lorem ipsum.
Create additional divs with styling.
File Location
For this module, you should be working in the following location:
Description
The <div>
tag defines a division in an HTML document. The <div>
tag is used to group block-elements to format them with CSS or JavaScript. By default, browsers always place a line break before and after the <div>
element. However, this can be changed with CSS.
Sample Code
Discussion
Let's break this block of code down a little bit: You're probably starting to get used to reading code by now, and can recognize that we created a list at the top of our file and then created a series of divs that each contain an <h2>
and a <p>
tag. Our second and third divs have some minor inline styling and are rendered differently by the browser as a result.
Uses
The div
tag is everywhere you look. You'll use it in all your projects. This section addresses the fundamentals of this tag, but be prepared to see divs in every project you work on.
Challenge
Try creating new divs and altering the inline styling of the ones you've just made.
Last updated