CSS - Box-Model
CSS - Box-Model
Recall
• Styling in CSS
• Static Styling
• Selectors
• Type or Element | ID | Class
• Combining Selectors using “,”
• Inheritance Selectors
• Descendants | Child | General Sibling | Adjacent Sibling
• Attribute Selectors
• Dynamic Styling
• Pseudo-class (:)
• Link Pseudo-class (link | visited | hover | active)
• Form Pseudo-class (hover | focus | required | valid | invalid)
Elements
Block-level Inline-level
Displayed on their own line Do not change the flow of the
Have virtual boxes around them document
Examples: Examples:
• p • img
• all headings (h1 through h6) • a
• em
• div
• strong
• span
Fundamentals of Web Programming 3
The”BOX” Model
• Block-level HTML5 elements have a virtual box drawn around them based
on the box model
• CSS treats each element as a rectangular box
• When the browser renders an element using the box model, the content is
surrounded by padding, a margin and a border.
Welcome
Content Area
border-top
border-left border-right
border-bottom
Element 3
Element 1
Element2{display: none; }
Element 1 Element 1
Element 2
Element 3 Element 3