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:
<header> - Defines a header for a document or a section
<nav> - Defines a set of navigation links
<section> - Defines a section in a document
<article> - Defines an independent, self-contained content
<aside> - Defines content aside from the content (like a sidebar)
<footer> - Defines a footer for a document or a section
<details> - Defines additional detales that the user can open and close on demand
<summary> - Defines a heading for the <detales> element
There are four different techniques to create multicolumn layout. Each technique has its pros and cons:
CSS framework
CSS float property
CSS flexbox
CSS grid
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.