Chapter 5

Exploring the CSS Box Model

IN THIS CHAPTER

Bullet Wrapping your head around the CSS box model

Bullet Giving elements room to breathe with padding

Bullet Enclosing elements with borders

Bullet Keeping other elements at bay with margins

Bullet Setting the width and height of page elements

CSS comes with a huge number of tools and techniques that you can wield to make stubborn page elements behave themselves. Those tools and techniques form the bulk of this book, but just about everything you do as a CSS developer will in some way involve (or be influenced by) the CSS box model, which is the subject you delve into in this chapter. The box model is so fundamental to almost everything in CSS that you should consider this chapter to be the foundation for almost every other CSS topic in the book.

Getting to Know the Box Model

Every web page consists of a series of HTML tags, and each of those tags represents an element on the page. In the strange and geeky world known as Style Sheet Land, each of these elements ...

Get HTML & CSS Essentials For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.