CSS Layout Float

Websites often display content in mul tiple columns (like a magazine or a newspaper).

In this example, we have created a header, two columns/boxes and a footer. On smaller screens, the columns will stack on top of each other.

Resize the browser window to see the reponsive effect (you will learn more about this in our next chapter - HTML Responsive.)

Cities

London

London is capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.

Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.

CSS Layout Float

HTML has several semantic elements that define the different parts of a web page:

There are four different techniques to create multicolumn layout. Each technique has its pros and cons:

It is common to do entire web layouts using the CSS <float> property. Float is easy to lear - you just need to remember how the <float> and <clear> properties work. Disadvantages: float elements are tied to the document flow, which may harm the flexibility. Lear more about float in w3schools or my CSS Float and Clear chapter.

In this example, we have created a header, two columns/boxes and a footer. On smaller screens, the columns will stack on top of each other.

Resize the browser window to see the responsive effect (you will learn more about this in our next chapter - HTML Responsive.)

Cities

London

London is the capital of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.

Standing on the River Thames, London has been major settlement for two millennia, its history going back to its founding by the Romans, who name it "Loninium".

CSS Layout Flexbox

Use of flexbox ensures that elements behave predictably when the page layout must accommodate different screen sizes and different display devices. The CSS Grid Layout Module offers a grid-based layout system, with rows and columns, making it easier to design web pages without having to use floats and positioning.

In this example, we have created a header, two columns/boxes and a footer. On smaller screens, the column will stack on top of each other.

Resize the browser window to see the responsive effect.

Cities

London

London is the capital city of England. It is most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.

Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.