Divs

Now let's look at the div element (div stands for division). We use it to group other elements together:

<div>
	<h2>I am a heading in a div!</h2>
	<p>I am a paragraph in the same div!</p>
</div>

Although the div element is not visible on its own, it is very useful when we want to apply the same style to all elements nested within it. We can also apply different styles to the div element itself. We don't know what styles are yet, but we will learn about them in the CSS course.

A div only groups elements, though. It has no meaning of its own: it doesn't say whether its content is a menu, an article or the footer of the page, for example. At the end of the lesson on advanced HTML elements, we will meet elements that also group content, but on top of that say which part of the page it is: header, nav, main, footer and section.

Instructions

Create an opening tag <div> before the heading h2 with the text Description, then create a closing tag </div> after the paragraph p describing the domestic cat. Don't forget to indent the elements that are now children of the div element (with spaces or a tab).

Create an opening tag <div> before the heading h2 with the text Physiology, then create a closing tag </div> after the paragraph p starting with It is a crepuscular....

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

Back

4/10

Next