<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8">
<title>Bye bye, HTML4</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<p>Bye bye, HTML4</p>
</body>
</html>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
<title>Bye bye, XHTML!</title>
<link rel="stylesheet" href="style.css" />
</head>
<body id="home">
<p>Bye bye, XHTML!</p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Hello HTML5!</title>
<link rel="stylesheet" href="style.css" />
</head>
<body id="home">
<p>Hello HTML5!</p>
</body>
</html>
il nostro obiettivo è saper leggere, intepretare e scrivere la versione più recente dello standard
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Hello HTML5!</title>
<link rel="stylesheet" href="style.css" />
</head>
<body id="home">
<p>Hello HTML5!</p>
</body>
</html>
<!DOCTYPE html>
Tag - il vocabolario degli Elementi che possono essere utilizzati per comporre un documento HTML.
<tag>...</tag> <!-- OK -->
<tag>...</tag <!-- ERRORE: tag non chiuso -->
<tag/> <!-- OK: tag vuoto chiuso -->
<tag> <!-- VERIFICARE: OK solo per i `void elements`:
area, base, br, col, embed, hr, img, input, keygen,
link, meta, param, source, track, wbr
http://www.w3.org/TR/html5/syntax.html#void-elements
<!-- NOTA: e questo è un commento -->
il più semplice documento HTML è composto da:
<!DOCTYPE html>
<html>
<head></head>
<body></body>
</html>
<!DOCTYPE html>
<html>
<head></head>
<body></body>
</html>
<p>Il testo e la spaziatura in
html
si comportano in<br/> modo
particolare
</p>
<p>
...The Poem problem...
My Bonnie lies over the ocean.
My Bonnie lies over the sea.
My Bonnie lies over the ocean.
Oh, bring back my Bonnie to me.
</p>
<pre>
...The Poem problem...
My Bonnie lies over the ocean.
My Bonnie lies over the sea.
My Bonnie lies over the ocean.
Oh, bring back my Bonnie to me.
</pre>
<h1>Caratteri Speciali</h1>
<ul>
<li> > </li>
<li> < </li>
<li> & </li>
<li> ◯ </li>
<li> @ </li>
<li> ® </li>
<li> © </li>
<li> ⋯ </li>
</ul>
<h1>Header Level1</h1>
<h2>Header Level2</h2>
<h3>Header Level3</h3>
<hr>
<h4>Header Level4</h4>
<h5>Header Level5</h5>
<h6>Header Level6</h6>
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item ...</li>
</ol>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item ...</li>
</ul>
<html lang="el"> <!-- dichiarazione lingua del documento -->
<meta charset="uft-8"> <!-- dichiarazione set caratteri -->
<button disabled> <!-- attributo booleano -->
<body id="home"> <!-- unico elemento home -->
<p class="important r-menu"> <!-- uno degli elementi con classi
important e r-menu -->
<p>
<a href="01/html/fake-page.html">
Questo testo
</a>
è un link ad una pagina HTML presente su questa macchina.
</p>
<p>
<a href="http://www.google.it">
Questo testo
</a>
è un link ad una pagina sul Web.
</p>
<a href="http://www.google.it" target="_blank">
Vai su google.it
</a>
<p>
Se si imposta l'attributo target a "_blank",
il link verrà aperto in una nuova finestra/tab.
</p>
<p>
Per inserire un'immagine si usa un tag <img>
<br />
<img src="../../res/learn_alcacoop.jpg"
alt="HTML tutorial"
style="height: 64px;" />
</p>
Questa immagine è linkata ad un url:
<a href="http://getfirefox.com">
<img src="../../res/firefox-logo.png"
alt="HTML tutorial"
width="64" height="64" />
</a>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>TITLE</title>
<link rel="stylesheet" href="style.css" />
</head>
<body id="home">
<p>BODY</p>
</body>
</html>
<table border="1">
<tr>
<td>100</td>
</tr>
</table>
<table border="1">
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
</table>
<table border="1">
<tr>
<th>col1</th>
<th>col2</th>
</tr>
<tr>
<td>100</td>
<td>200</td>
</tr>
</table>
<table>
<thead>
<tr>
<th scope="col">Header 1</th>
<th scope="col">Header 2</th>
</tr>
</thead>
<tfoot>
<tr>
<td>Footer 1</td>
<td>Footer 2</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
<tr>
<td>Cell 7</td>
<td>Cell 8</td>
</tr>
</tbody>
</table>
La tabella è spesso scambiata per una comoda scorciatoia per il layouting di una pagina...
<!DOCTYPE html>
<html>
<head>
<title>Table Layout Temptation</title>
<link rel="stylesheet"
href="06_table5.css"/>
</head>
<body>
<table>
<tr id="header">
<td colspan="2">HEADER</td>
</tr>
<tr id="page-body">
<td id="sidebar">SIDEBAR</td>
<td id="content">CONTENT</td>
</tr>
<tr id="footer">
<td colspan="2">FOOTER</td>
</tr>
</table>
</body>
</html>
Purtroppo questo approccio presenta diversi problemi, tutti riconducibili alla mancata/errata separazione tra aspetto e contenuto, in particolare:
Per fortuna i fogli di stile CSS consentono di risolvere il problema con maggiore eleganza e flessibilità e ha consentito la deprecazione di questo approccio già diversi anni fa.
<div id="page-header">
<h1>Site Title</h1>
<div id="page-nav">
<ul>
<li><a href="./home.html">Home</a></li>
<li><a href="./about.html">about</a></li>
</ul>
</div>
</div>
<div id="page-content">
<div id="article">
<div id="article-header">
<h1>Article Title</h1>
<span id="article-pubdate">02 Gennaio 2014</span>
</div>
<div id="article-content">
Content...
</div>
</div>
<div id="related-articles">
Related...
</div>
</div>
<div id="page-footer">
<a href="#page-header">Back to top</a>
</div>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Site Name - Article Title</title>
</head>
<body>
<header id="site"> <!-- Page Header -->
<h1>Site Name</h1>
</header>
<nav> <!-- Site Navbar -->
<ul><li>Navbar Item</li></ul>
</nav>
<div id="content">
<article> <!-- article -->
<header> <!-- title e metadata -->
<h1>Article Title</h1>
<p>Article Metadata</p>
</header>
<!-- content e footer -->
<p>Article Content</p>
<footer>Article Footer</footer>
</article>
<!-- article secondary content -->
<aside id="sidebar">
<h3>Related Articles</h3>
<p>...</p>
</aside>
</div>
<!-- site footer -->
<footer id="footer">Page Footer</footer>
</body>
</html>
<form id="login-form" action="process.php" method="POST">
<fieldset>
<legend>Login</legend>
<div>
<label for="email">Email:</label>
<input name="email" type="email"
placeholder="your email address"
required autofocus>
</div>
<div>
<label for="password">Password:</label>
<input name="password" type="password"
placeholder="6 chars password" required>
</div>
<div>
<input name="login" type="submit" value="Login">
</div>
</fieldset>
</form>
<form onsubmit="return false"
oninput="o.value = parseInt(a.value) + parseInt(b.value)">
<input name="a" type="number" step="any"> +
<input name="b" type="number" step="any"> =
<output name="o"></output>
</form>