When coding in HTML, it can be beneficial to divide our code up into sections. We use <div> tags to do this.
Div tags go inside the <body> tags and you can place them around sections of code. In the code example below we have 2 sets of <div> tags, with the highlighted area showing what is within each <div> tag.
<!DOCTYPE html> <html> <head> <title>Bold and Italics</title> </head> <body> <h1> Website Name </h1> <div> <h2>First Heading</h2> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> </div> <div> <h2>Second Heading</h2> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> </div> </body> </html> |
<div> tags in plain form don’t actually change the HTML page visibly. But you can use <div> with formatting and applying other properties in CSS. We go over how to use them as such in our next course but until then, think of them as a way to organize your code.
Below is a video going over <div> tags.