Webentwicklung Anfänger

HTML & CSS: Deine erste Webseite

Jede Webseite besteht aus HTML und CSS. HTML definiert die Struktur (Text, Bilder, Links), CSS das Aussehen (Farben, Layout, Abstände).

HTML - Die Struktur

HTML steht für HyperText Markup Language. Es besteht aus Tags, die Inhalte umschließen:

<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <title>Meine Webseite</title>
</head>
<body>
    <h1>Willkommen!</h1>
    <p>Das ist meine erste Webseite.</p>
</body>
</html>

Wichtige HTML-Tags

<!-- Überschriften -->
<h1>Hauptüberschrift</h1>
<h2>Unterüberschrift</h2>
<h3>Kleinere Überschrift</h3>

<!-- Text -->
<p>Ein Absatz mit Text.</p>
<strong>Fetter Text</strong>
<em>Kursiver Text</em>

<!-- Links -->
<a href="https://example.com">Klick hier</a>

<!-- Bilder -->
<img src="bild.jpg" alt="Bildbeschreibung">

<!-- Listen -->
<ul>
    <li>Punkt 1</li>
    <li>Punkt 2</li>
</ul>

<!-- Container -->
<div>Block-Element</div>
<span>Inline-Element</span>

CSS - Das Design

CSS steht für Cascading Style Sheets. Du kannst CSS direkt in HTML einbetten oder eine externe Datei nutzen.

CSS in HTML einbetten

<head>
    <style>
        h1 {
            color: blue;
            font-size: 32px;
        }
    </style>
</head>

Externe CSS-Datei (empfohlen)

<head>
    <link rel="stylesheet" href="style.css">
</head>

Grundlegende CSS-Eigenschaften

/* Farben */
h1 {
    color: #333333;           /* Textfarbe */
    background-color: #f0f0f0; /* Hintergrund */
}

/* Schrift */
p {
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
    line-height: 1.5;
}

/* Abstände */
div {
    margin: 20px;    /* Außenabstand */
    padding: 10px;   /* Innenabstand */
}

/* Rahmen */
.box {
    border: 2px solid black;
    border-radius: 8px;
}

/* Größe */
img {
    width: 100%;
    max-width: 500px;
}

Selektoren

/* Element-Selektor */
p { color: black; }

/* Klassen-Selektor */
.highlight { background: yellow; }

/* ID-Selektor */
#header { height: 100px; }

/* Kombinationen */
.card p { margin: 10px; }

Flexbox - Modernes Layout

Flexbox macht Layouts einfach:

.container {
    display: flex;
    justify-content: space-between; /* Horizontal */
    align-items: center;            /* Vertikal */
    gap: 20px;                      /* Abstand */
}

.item {
    flex: 1; /* Gleiche Breite für alle */
}

Praktisches Beispiel

HTML (index.html)

<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mein Portfolio</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
        <h1>Max Mustermann</h1>
        <p>Web Developer</p>
    </header>

    <main>
        <section class="about">
            <h2>Über mich</h2>
            <p>Ich bin ein angehender Webentwickler und lerne gerade HTML und CSS.</p>
        </section>

        <section class="projekte">
            <h2>Meine Projekte</h2>
            <div class="cards">
                <div class="card">
                    <h3>Projekt 1</h3>
                    <p>Beschreibung des Projekts</p>
                </div>
                <div class="card">
                    <h3>Projekt 2</h3>
                    <p>Beschreibung des Projekts</p>
                </div>
            </div>
        </section>
    </main>

    <footer>
        <p>&copy; 2026 Max Mustermann</p>
    </footer>
</body>
</html>

CSS (style.css)

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, sans-serif;
    line-height: 1.6;
    color: #333;
}

header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    text-align: center;
    padding: 4rem 2rem;
}

main {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

section {
    margin-bottom: 3rem;
}

h2 {
    margin-bottom: 1rem;
    color: #667eea;
}

.cards {
    display: flex;
    gap: 1rem;
}

.card {
    flex: 1;
    padding: 1.5rem;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

footer {
    text-align: center;
    padding: 2rem;
    background: #f5f5f5;
}

Nächste Schritte

  1. Responsive Design - Für Handys optimieren
  2. CSS Grid - Komplexere Layouts
  3. JavaScript - Interaktivität hinzufügen

Experimentiere mit dem Code und hab Spaß!