Solved

CSS: 960px container

Posted on 2015-01-05
6
27 Views
Last Modified: 2016-05-11
Hello Experts,

I am curious. I am fairly new to CSS and web design. Well, fairly new to designing websites correctly... Anyway, I am taking a few courses right now from Team Treehouse. I am really enjoying their classes. In one of the lessons, I noticed the code was like this:

<body>
  <header>
  </header>
  <div id="wrapper">
    <section>
    </section>
    <footer>
    </footer>
  </div>
</body>

The associated CSS sets the wrapper to this:

#wrapper {
  max-width: 960px;
  margin: 0 auto;
  etc.
  etc.
  etc.
}

Why wouldn't the header be included within the wrapper ID?
0
Comment
Question by:extremedesign413
  • 2
6 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 334 total points
ID: 40531339
Perhaps the design is for a page where the header spans the entire width of the browser window regardless of size and the content (inside the wrapper) spans the entire width up to 960px wide. At that point it's fixed at 960px in width and is centered left to right in the browser window (margin: 0 auto). If the header were inside the wrapper, and it could be, it would also be fixed at a maximum of 960px wide. I say "perhaps" because we don't have the css for the header.
0
 

Author Comment

by:extremedesign413
ID: 40531342
@Tom Beck:

Would it be considered wrong or incorrect to include it within the ID wrapper?
0
 
LVL 38

Assisted Solution

by:Tom Beck
Tom Beck earned 334 total points
ID: 40531380
No. It depends on what you want your finished page to look like.

Realize that <header>, <section> and <footer> are specific content containers whereas <div> is a generic container. They are all block elements and are interpreted by and behave the same in any web browser with regards to normal flow layout. In your example, the <div> container is being used to wrap sections of the page together so that css can be applied to the group as a whole. It is not an essential construct to the design of a web page. Tags like <header> were created to make html markup more readable and subsequently easier to troubleshoot. Before HTML5 these containers would have all been generic <div>s.
0
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 166 total points
ID: 40531812
<header>, <section>, and <footer> along with a number of other tags are new for HTML5 as part of a move to a more semantic approach to markup.  what they do in the page is unpredictable if the page does not contain a valid HTML doctype.  They are also not recognized in TE versions prior to IE9 and it requires that a bit of code be added to define them for those older browser otherwise the rendering becomes unpredictable.

As for keeping the header outside of the narrower portion of the page it might be that the header includes a banner add that controls the width from its own styles or script.

However what you have posted is just an out of context fragment.  Without the full page and the requirements it is impossible to tell if the CSS is going to produce the desired page layout and rendering.

Cd&
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adding a countdown to HTA 12 92
Session on Html 8 37
Two decimal 5 25
Flex container in CSS 8 21
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question