CSS CSS Layout Basics Getting Started with CSS Layout Centering Page Content and Creating a Full-width Header

Why was the wrapper for the header added inside of the <header> tag instead of outside it?

In the HTML for this video the instructor adds the <div class='container'> code inside the <header> tag while i suppose a container should be outside the header right?

2 Answers

Hi Sachin

Putting a container around the content allows you to keep the content in the center of the browser. So in the video, the header is styled to have a green background at 100% width but if the container was to be added around the header as well this would mean that the header would only span 70% of the width and the green background wouldn't go outside of this container.

Steven Parker
Steven Parker
203,995 Points

It depends on what is being contained.

In this case, it's the contents of the header, not the header itself. This allows different styling to be applied to the header as a whole, and separately to the contents.