One of the listservs I read regularly recently had the question posted, “What is a wrapper?” An answer provided by Paul Novitski was so clear that I thought it might be a useful tip here. With Paul’s permission, here is his response to the question.
A wrapper is an element, commonly a div, that encloses one or more other
elements in the HTML markup, e.g.:
<div id="wrap">
<h1>Headline</h1>
<p>Paragraph</p>
<p>Paragraph</p>
</div>
The purposes of wrappers are several, including:
- to group elements semantically, for instance to separate page heading
from body text from sidebar from footer. - to group elements cosmetically, such as with a surrounding border or a
common background image or color. - to group elements in layout, such as to keep them all in the same column
when columns are floated next to one another. - to enable special positioning, as when a wrapper is given relative
positioning in order to contain child elements with absolute positioning. - to make it more convenient to specify elements in CSS and JavaScript by
referring to their parent, without having to id or class each child
element, as in:
div#wrap h1 {...}
div#wrap p {...}
var aKids = document.getElementById("wrap")
.childNodes;
(Note: thevarabove should all be on one line)
Some special effects require several nested wrappers, such as when a box is
given rounded corners.
Stumble it!







4 Comments
The best thing to do is to grab Firebug, and begin analyzing others web sites. You’ll begin to see the trend on how divs are used across several sites.
.-= Wayne John´s last blog ..The poll results are in, web development it is =-.
Thanks! From your post, now I know why they called it “wrapper”
.-= John Wesley´s last blog ..Hello world! =-.
I must confess that this is a great and very useful information to me. Thank you so much for this.
.-= Uche Nwaobi´s last blog ..Improve Usability of Your Website =-.
Thanks for the explanation, I usually use master or main, although using wrapper div makes my code easier and more clear.
COngratulations for the post.
What can you contribute?