Solved

CSS: 960px container

Posted on 2015-01-05
6
24 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
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…

809 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