tutoriais mais recente desenvolvimento web

Layouts HTML


Sites, muitas vezes exibir conteúdo em várias colunas (like a magazine or newspaper) .


Galeria de arte City

Londres
Paris
Tóquio

Londres

Londres é a cidade capital da Inglaterra. É a cidade mais populosa do Reino Unido, com uma área metropolitana de mais de 13 milhões de habitantes.

De pé sobre o rio Tamisa, Londres tem sido um grande povoado por dois milênios, a sua história que remonta à sua fundação pelos romanos, que o nomeou Londinium.

Copyright © w3ii.com

HTML Layout Usando <div> Elements

O <div> elemento é frequentemente utilizado como uma ferramenta de layout, porque pode ser facilmente posicionado com CSS.

Este exemplo usa quatro <div> elementos para criar um layout de coluna múltipla:

Exemplo

<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>
Tente você mesmo "

O 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>

Disposição site usando HTML5

HTML5 oferece novos elementos semânticos que definem diferentes partes de uma página web:

HTML5 elementos semânticos
  • <header> - Define um cabeçalho para um documento ou uma seção
  • <nav> - Define um recipiente para links de navegação
  • <section> - Define uma seção em um documento
  • <article> - Define um artigo autónomo independente
  • <aside> - Define o conteúdo de lado a partir do conteúdo (like a sidebar)
  • <footer> - Define um rodapé de um documento ou de uma seção
  • <details> - Define detalhes adicionais
  • <summary> - Define um título do <details> elemento

Este exemplo usa <header> , <nav> , <section> , e <footer> para criar um layout de coluna múltipla:

Exemplo

<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>
Tente você mesmo "

O 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>

HTML Layout Usando tabelas

O <table> elemento não foi projetado para ser uma ferramenta de layout.
O objetivo do <table> elemento é para exibir dados tabulares.

Layout pode ser alcançada usando o <table> elemento, porque os elementos da tabela podem ser decorados com CSS:

Exemplo

<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>
Tente você mesmo "

O CSS:

<style>
table.lamp {
    width:100%;
    border:1px solid #d4d4d4;
}
table.lamp th, td {
    padding:10px;
}
table.lamp th {
    width:40px;
}
</style>

Aviso: Criação de layout com tabelas não é errado, mas não é recomendado! Evite tabelas para a criação de layout.