Build a Nutrition Label - Step 16 (<div> vs <hr>)

Hey,

Just a quick question: why does step 16 create and style a div element for a divider instead of just styling the hr element? Is there some benefit or “in the know” reason I am not aware of?

Thanks!

I think its because then you can specify the style of your divider and later you will need to have some bold and double dividers.

2 Likes

Thanks! I thought you could also add classes and style hr elements so wasn’t sure about the choice

Well technically you can add styling to an hr element but the reason this step uses a div instead is because its semantic to use hr when separating different parts of a content so that the screen reader will see them as seperaters and to use a div element when the purpose of your border is just to add styling to your page and change the look of it.

2 Likes

Thanks for explaining!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.