Why add the id attribute to a <div> tag and not a <p> tag?

Step 14 of the fashion blog exercise tells me to add the id attribute to a newly created div tag. I can accomplish the same thing by instead adding the id attribute to the p tag and leaving out the div tags. Superfluous code is bad code, so why do the instructions tell me to do it this way?


think the purpose is to make it like a container (cause div means division), so your code looks more easier to read for other programmer and to style in CSS/Javascript. It’s not wrong if you put it in P tags, just matter of preferences and way of coding.

1 Like

Because CSS should flow like a waterfall and you should only use exceptions when necessary.
So the id for contact will allow you to control everything more effectively from the element route, such as padding, styling for that entire block.

If you just target the p tag child then you lose control over the block.
Block level control = less and more accurate CSS for specificity if needed.

1 Like