Latest news

div & ID element freedcodecamp

No comments

The div element, also known as a division element, is a general purpose container for other elements.
The div element is probably the most commonly used HTML element of all. It’s useful for passing the CSS of its own class declarations down to all the elements that it contains.
Just like any other non-self-closing element, you can open a div element with

and close it on another line with

.
Try putting your opening div tag above your “Things cats love” p element and your closing div tag after your closing ol tag so that both of your lists are within one div.
Nest your “Things cats love” and “Things cats hate” lists all within a single div element.

One cool thing about id attributes is that, like classes, you can style them using CSS.
Here’s an example of how you can take your element with the id attribute of cat-photo-element and give it the background color of green. In your style element:
#cat-photo-element {
background-color: green;
}
Note that inside your style element, you always reference classes by putting a . in front of their names. You always reference ids by putting a # in front of their names.
Try giving your form, which now has the id attribute of cat-photo-form, a green background.

Things cats love:

  • cat nip
  • laser pointers
  • lasagna

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats
wpadmindiv & ID element freedcodecamp

Leave a Reply

Your email address will not be published. Required fields are marked *