One of the most important CSS webpage layout concepts to understand is the box model. Every element on a webpage is actually a rectangular box. Exactly how a box will display depends upon the positioning method used, which other CSS properties you set for the box and how you select the box.
Welcome to Bucaro TecHelp!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

[About BTH]  [User Agreement]  [Privacy Policy]  [Site Map]  [Contact Form]  [Advertise on BTH]  [News Feed]

Google
Web
This Site

The CSS Box Model

One of the most important CSS webpage layout concepts to understand is the box model. Every element on a webpage is actually a rectangular box consisting of a content area surrounded by a border. The border is invisible because, by default, its width is set to 0. You can make the border visible by setting the boxes border-style property to solid or one of the other available styles.

The CSS Box Model

Padding

The area between a boxes content area and its border is its padding. By default the padding is set to 0. You can use the padding property to set the size of the padding area. Padding cannot be set to negative values.

Text in the boxes content area

<span style="border-style:solid; padding:10px;">
Text in the boxes content area
</span>

If you set a background color or background image for a box, it will appear within the content area and padding area.

Content Area
Content Area
Content Area
Content Area


<style type="text/css">
.box1
{
float:left;
padding:4px;
margin:4px;
border-style:solid;
border-width:1px;
background-color:#ba55d3;
}
</style>

<div class="box1">Content Area</div>
<div class="box1">Content Area</div>
<div class="box1">Content Area</div>
<div class="box1">Content Area</div>

The CSS Box Model is NOT Consistently Implemented

Exactly how a box will display depends upon the positioning method used, e.g. fixed, relative, inline, block, float, etc. It also depends upon which other CSS properties you set for the box and how you select the elements they apply to, e.g. inline, class, id, etc. It is therefor important to test your layout with Internet Explorer, Firefox, and any other browsers for which you desire to be compatible.

Web Design Sections

RSS Feed RSS Feed

Cascading Style Sheets
Understanding CSS Selectors
The CSS Box Model
Understanding CSS Positioning
Add Style to Your Blockquotes
Display Overlapping Images on Your Webpage
Add Drop Shadows to Your Pictures
Style Your Imagemap Tooltips
How to Style a List
How to Style a Table
How to Change the Mouse Pointer
How to Use a Starburst on Your Web Page
How to Use a Pull Quote
Easy Scrollable Area Code
Easy CSS Buttons
Create CSS Button Rollovers
Create Custom Horizontal Rules
Easy CSS Popup Windows
Easy Visual Effects to Spice Up Your Webpage
Spice Up Your Web Forms with Color and Graphics
Setting a Larger First Letter
Make a Fixed-width Variable-height Round Cornered Box
HTML, XHTML, and CSS Bible
Web Designer's Reference
Pro CSS Techniques
Code for Horizontal Drop-down Menu Bar
Easy Rollover Menu Code
Easy CSS Tabbed Navigation
Easier Expanding Menu Code
Easy Three-level Expanding Menu Code
Easy Floating Menu Code


Your Career Quiz
[Site User Agreement]  [Advertise on This site]  [Search This Site]  [Contact Form]
Copyright©2001-2009 Bucaro TecHelp P.O.Box 18952 Fountain Hills, AZ 85269