Nachschlagen: HTML
Grundgerüst
html
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Titel im Tab</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
…
</body>
</html>In VS Code: In einer leeren .html-Datei ! tippen und Tab drücken. Die Zeile mit viewport sorgt dafür, dass die Seite auf dem Handy nicht winzig dargestellt wird.
Text
| Element | Bedeutung |
|---|---|
<h1> … <h6> | Überschriften |
<p> | Absatz |
<strong>, <em> | wichtig (fett), betont (kursiv) |
<br> | Zeilenumbruch |
<hr> | waagrechte Trennlinie |
<blockquote> | Zitat |
<code> | Code im Text |
<small>, <mark>, <sub>, <sup> | klein, markiert, tiefgestellt, hochgestellt |
<!-- … --> | Kommentar |
Links und Bilder
html
<a href="https://example.com">externer Link</a>
<a href="kontakt.html">andere Seite im selben Ordner</a>
<a href="#hobbys">Sprung zum Element mit id="hobbys"</a>
<a href="https://example.com" target="_blank">in neuem Tab öffnen</a>
<a href="mailto:name@example.com">E-Mail schreiben</a>
<img src="bilder/katze.jpg" alt="Beschreibung des Bilds" width="300">Struktur
| Element | Bedeutung |
|---|---|
<header>, <footer> | Kopf- und Fussbereich |
<nav> | Navigation |
<main> | Hauptinhalt (einmal pro Seite) |
<section> | thematischer Abschnitt |
<article> | in sich abgeschlossener Inhalt (Blogeintrag, Karte) |
<aside> | Nebeninhalt (Seitenleiste) |
<div>, <span> | neutrale Behälter (Block bzw. in der Zeile) |
Listen
html
<ul> <li>Punkt</li> </ul> <!-- Aufzählung -->
<ol> <li>Schritt</li> </ol> <!-- nummeriert -->Tabellen
html
<table>
<thead>
<tr><th>Name</th><th>Art</th></tr>
</thead>
<tbody>
<tr><td>Buddy</td><td>Hund</td></tr>
<tr><td>Minka</td><td>Katze</td></tr>
</tbody>
</table><tr> ist eine Zeile, <th> eine Kopfzelle, <td> eine normale Zelle. Mit <td colspan="2"> geht eine Zelle über zwei Spalten.
Formulare
html
<label for="name">Name:</label>
<input type="text" id="name" placeholder="Dein Name" required>| Feld | Code |
|---|---|
| Text | <input type="text"> |
| Zahl | <input type="number" min="0" max="100" step="1"> |
<input type="email"> | |
| Passwort | <input type="password"> |
| Datum | <input type="date"> |
| Farbe | <input type="color"> |
| Schieberegler | <input type="range" min="0" max="100"> |
| Checkbox | <input type="checkbox"> |
| Auswahl (eine aus mehreren) | <input type="radio" name="gruppe" value="a"> (gleicher name = eine Gruppe) |
| Auswahlliste | <select><option value="hund">Hund</option></select> |
| mehrzeilig | <textarea rows="4"></textarea> |
| Knopf | <button>Senden</button> |
Medien
html
<video src="film.mp4" controls width="400"></video>
<audio src="lied.mp3" controls></audio>
<!-- YouTube: auf YouTube «Teilen → Einbetten» wählen und den Code kopieren -->
<iframe src="https://www.youtube.com/embed/VIDEO-ID" width="560" height="315"></iframe>Attribute für alle Elemente
| Attribut | Wofür |
|---|---|
class="a b" | eine oder mehrere Klassen (für CSS und JS) |
id="eindeutig" | eindeutiger Name (nur einmal pro Seite) |
title="…" | Tooltip beim Darüberfahren |
style="color: red;" | CSS direkt am Element (besser: in der CSS-Datei) |
Sonderzeichen
| Zeichen | Code |
|---|---|
< und > | < und > |
& | & |
| geschütztes Leerzeichen | |
© | © |
Mehr: MDN Web Docs: HTML