I siti Web spesso vengono visualizzati i contenuti in più colonne (like a magazine or newspaper) .
Galleria Civica
Parigi
Tokyo
Londra
Londra è la capitale dell'Inghilterra. E 'la città più popolosa del Regno Unito, con un'area metropolitana di oltre 13 milioni di abitanti.
In piedi sul fiume Tamigi, Londra è stata un importante insediamento per due millenni, la sua storia che risale alla sua fondazione da parte dei Romani, che la chiamarono Londinium.
Layout HTML Utilizzando <div> Elementi
Il <div> elemento è spesso usato come uno strumento di layout, in quanto può essere facilmente posizionato con i CSS.
Questo esempio utilizza quattro <div> elementi per creare un layout a più colonne:
Esempio
<body>
<div id="header">
<h1>City Gallery</h1>
</div>
<div id="nav">
London<br>
Paris<br>
Tokyo
</div>
<div id="section">
<h1>London</h1>
<p>London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.</p>
<p>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.</p>
</div>
<div id="footer">
Copyright © w3ii.com
</div>
</body>
Prova tu stesso " Il CSS:
<style>
#header {
background-color:black;
color:white;
text-align:center;
padding:5px;
}
#nav {
line-height:30px;
background-color:#eeeeee;
height:300px;
width:100px;
float:left;
padding:5px;
}
#section {
width:350px;
float:left;
padding:10px;
}
#footer {
background-color:black;
color:white;
clear:both;
text-align:center;
padding:5px;
}
</style>
Layout sito web utilizzando HTML5
HTML5 offre nuovi elementi semantici che definiscono le diverse parti di una pagina web:
![]() |
|
Questo esempio utilizza <header> , <nav> , <section> , e <footer> per creare un layout a più colonne:
Esempio
<body>
<header>
<h1>City Gallery</h1>
</header>
<nav>
London<br>
Paris<br>
Tokyo
</nav>
<section>
<h1>London</h1>
<p>London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.</p>
<p>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.</p>
</section>
<footer>
Copyright © w3ii.com
</footer>
</body>
Prova tu stesso " Il CSS:
<style>
header {
background-color:black;
color:white;
text-align:center;
padding:5px;
}
nav {
line-height:30px;
background-color:#eeeeee;
height:300px;
width:100px;
float:left;
padding:5px;
}
section {
width:350px;
float:left;
padding:10px;
}
footer {
background-color:black;
color:white;
clear:both;
text-align:center;
padding:5px;
}
</style>
Layout HTML Utilizzo di tabelle
Il <table> elemento non è stato progettato per essere uno strumento di layout.
Lo scopo del <table> elemento è quello di visualizzare i dati tabulari.
Layout può essere raggiunto utilizzando il <table> elemento, perché gli elementi della tabella possono essere in stile con i CSS:
Esempio
<body>
<table class="lamp">
<tr>
<th>
<img src="../images/lamp.jpg" alt="Note" style="height:32px;width:32px">
</th>
<td>
The table element was not designed to be a layout tool.
</td>
</tr>
</table>
</body>
Prova tu stesso " Il CSS:
<style>
table.lamp {
width:100%;
border:1px solid #d4d4d4;
}
table.lamp th, td {
padding:10px;
}
table.lamp th {
width:40px;
}
</style>
Attenzione: La creazione di layout con le tabelle non è sbagliato, ma non è consigliabile! Evitare tabelle per la creazione di layout.