CSS

Div "containers" Div "wrappers"

Im always using the "View source code" on websites I like, to see how they did something and I notice a lot of "Container" class or "wrapper" class

2 questions

1st. What exactly are those?

2nd. Why do people specifically name them those words and not whatever they want? is it a set standard?

Thanks you

4 Answers

Wayne Priestley
Wayne Priestley
19,563 Points

container or wrapper is the term most people use to describe the div that contains the whole page.

Its not a standard that they call it container or wrapper, but its a good description and as you have seen most people use it.

James Barnett
James Barnett
37,529 Points

> Its not a standard that they call it container or wrapper

The distinction here is a convention vs a standard.

Kevin Korte
MOD
Kevin Korte
Treehouse Moderator 27,426 Points

Yes, containers and wrappers are just terms. The actual word "container" or "wrapper" means nothing. It just connects CSS from the CSS file to that div. Container and wrapper often mean the same thing on a website, just depends on the developer and what they enjoy using.

A container or wrapper is a dummy div used for purposes of setting backgrounds, floats or padding on another div. Sometimes you need an parent div to get a block level element to do what you want, whether that's simply setting a background or using margin: 0 auto to center a block. People just call them wrappers out of custom and also that it's a very uncommon need for a class name. It means nothing technically.

Thank you All!