1 / 9

Understanding the CSS Box Model: Borders, Margins, and Padding

This overview explores the CSS Box Model, which defines how every element in a web document is structured as a rectangular box. It breaks down the key components: content area, padding, borders, and margins. Learn how to control the appearance of borders using properties like border-style, border-width, and border-color. The tutorial also covers setting margins and padding for spacing within your layout. Gain insights into using div tags effectively for creating multi-column layouts, enhancing your web design skills.

Download Presentation

Understanding the CSS Box Model: Borders, Margins, and Padding

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. More CSSPage layout Boriana Koleva Room: C54 Email: bnk@cs.nott.ac.uk

  2. Overview • The Box Model • Borders • Margins and padding • Using div tags with the box model

  3. The Box Model • Each element in a document is considered to be a rectangular box consisting of content area, padding, a border and margins

  4. Borders • Every element has a border-style property • Controls whether the element has a border and if so, the style of the border • border-style values: none, dotted, dashed, and double • border-width values: thin, medium (default), thick, or a length value in pixels • Border width can be specified for any of the four borders (e.g., border-top-width)

  5. Borders • border-color – any color • Border color can be specified for any of the four borders (e.g., border-top-color http://www.cs.nott.ac.uk/~bnk/WPS/border.html

  6. Margins • The space between the border of an element and its neighbor element • The margins around an element can be set with margin-left, etc. - just assign them a length value <img src = "c210.jpg" style = "float: right; margin-left: 0.35in; margin-bottom: 0.35in" />

  7. Padding • The distance between the content of an element and its border • Controlled by padding, padding-left, etc. http://www.cs.nott.ac.uk/~bnk/WPS/marpads.html

  8. div tags with the box model • An example of a two-column page layout • Left-column navigation • Right-column logo and content http://www.cs.nott.ac.uk/~bnk/WPS/twocolumn.html

More Related