If we want to expand an element’s tag, we can do so using an attribute. Attributes are content added to the opening tag of an element and can be used in several different ways, from providing information to changing styling. Attributes are made up of the following two parts:
- The name of the attribute
- The value of the attribute
One commonly used attribute is the id
. We can use the id
attribute to specify different content (such as <div>
s) and is really helpful when you use an element more than once. id
s have several different purposes in HTML, but for now, we’ll focus on how they can help us identify content on our page.
When we add an id
to a <div>
, we place it in the opening tag:
<div id="intro"> <h1>Introduction</h1> </div>
Instructions
Add an id
attribute with the value "introduction"
to the <div>
tag that’s below the The Brown Bear
<h1>
heading.
Add an id
attribute with the value "habitat"
to the opening <div>
tag that has the Habitat
<h2>
heading as a child.
Add an id
attribute with the value "media"
to the opening <div>
tag that has the Media
<h2>
heading as a child.