© Mikael Olsson 2019
Mikael OlssonCSS3 Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-4903-1_26

26. Layout

Mikael Olsson1 
(1)
Hammarland, Finland
 

There are many ways to create a layout in CSS. This chapter will look at some of these methods and how they compare when creating a simple layout.

Float

In the early days of CSS one of the few available methods for creating a grid-like design was to use the float property to get block elements to stay on the same line.
.left { float: left; }
.clear { clear: both; }
To show the effect of floating elements the following box style will be used.
.box {
  width: 100px;
  height: 100px;
  margin: 1em;
  background: #ccc;
}
Clearing issues and browser inconsistencies aside, the float property provided a non-intuitive ...

Get CSS3 Quick Syntax Reference: A Pocket Guide to the Cascading Style Sheets Language 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.