Chapter 8CSS Positioning Basics

In this chapter, we will look in further depth at some of the vital concepts when positioning page elements using CSS. If you’re reading this book chapter by chapter, you’ll already have come across some of these concepts used in the examples. Here we’ll take a proper look at them, and see how they can be used in combination to layout our pages and components.

How do I decide when to use a class and when to use an ID?

At first glance, classes and IDs seem to be used in much the same way: you can assign CSS properties to both classes and IDs, and apply them to change the way HTML elements look. But in which circumstances are classes and IDs best applied?


The most important rule where classes and IDs ...

Get The CSS3 Anthology, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.