Join James Williamson for an in-depth discussion in this video Margins & padding, part of CSS Fundamentals.
- View Offline
- [Voiceover] After our overview of the box model,…I want to take a moment to familiarize you…with the individual properties of the box model,…and I want to start with margins and padding.…Padding is the space inside of elements…that hold the contents of an element…away from its edge.…You can specify padding in several ways.…First, you can define padding individually…for each side of an element.…Now keep in mind, however, that setting padding…in only one direction is not the same…as setting padding to zero in other directions.…
Any existing padding on other sides…is still going to apply.…You can also use shorthand notation…when defining padding.…There are four variations on padding shorthand.…First, you can define four separate values,…separated by white spaces.…Now, these values are going to apply, in order,…to the top, right, bottom,…and left sides, respectively.…Now, if you use three values, the first value will be…applied to the top, the second value for the left…and right sides, and the last value will be…applied to the bottom.…
CSS Fundamentals covers the basic concepts, terminology, and techniques you need to read and write CSS. It's for people who want a big-picture overview before taking hands-on courses. Author James Williamson explains how CSS affects text, borders, backgrounds, and images; how CSS works with HTML; and how the W3C's evolving CSS specification impacts designers. He also reviews some of the most popular CSS editors and frameworks and lists online tools and resources for further study.
- What is CSS?
- Basic selector types
- Using CSS with HTML
- How browsers render CSS differently
- Exploring CSS specifications
- Checking browser support
- Working with fonts
- Understanding the box model
- Adjusting margins and padding
- Positioning elements
- Basic CSS layout concepts
- Media types and media queries
- Working with CSS frameworks and CSS grids