# für Commit vormerken
git commit -m "feat: ..." # Conventional Commits
git push # hochladen
git pull --rebase # neueste Änderungen holen
```
---
# Projekt-Skeleton
```bash
mkdir mein-projekt && cd mein-projekt
git init
npm init -y # erzeugt package.json
echo "node_modules" > .gitignore
echo ".env" >> .gitignore
npm install express
```
**`package.json` minimal:**
```json
{
"name": "mein-projekt",
"version": "0.1.0",
"type": "module",
"scripts": {
"start": "node index.js",
"dev": "node --watch index.js"
}
}
```
`.env` für Secrets (nie committen!), `.env.example` mit Dummy-Werten committen.
---
# HTML – Hypertext Markup Language
---
# Was ist HTML? (1/2)
**H**yper**T**ext **M**arkup **L**anguage
- **Keine** Programmiersprache
- Am ehesten eine Formattierungssprache
- Beschreibt **Struktur und Aufbau** einer Webseite
```html
Das ist ein Absatz.
```
Erfunden 1989 von Tim Berners-Lee. Aktuelle Version: HTML5 (seit 2014).
---
# Was ist HTML? (2/2)
- Mit HTML werden **HTML-Dokumente** beschrieben (`index.html`)
- Ein HTML-Dokument beschreibt das **Document Object Model (DOM)**
- Der DOM ist eine **hierarchische Baumstruktur** (Eltern, Kinder, Geschwister)
- *parent* nodes / elements
- *child* nodes / elements
- *sibling* nodes / elements
In HTML sprechen wir von **Elementen**, in JavaScript eher von **Nodes**.
---
# HTML-Anatomie (1/2)
Formattierungssprache mit strenger Syntax:
```
...
```
- Öffnende und schließende Tags müssen identisch sein
- Schließendes Tag hat ein `/` nach der Spitzklammer
---
# HTML-Anatomie (2/2)
Wir unterscheiden **umschließende** und **selbst-schließende** Tags.
**Umschließend:**
- ` ... ` – fett-gedruckter Text (inline)
- ` ... ` – Hyperlink
- ` ... ` – sichtbarer Teil eines HTML-Dokuments
- ` ... ` – Aufklapp-Text / Akkordion
**Selbst-schließend:**
- ` ` – Bild, Vektorgrafik
- ` ` – Eingabefeld
- ` ` – Metadaten
---
# Darstellungsebene und Metadaten
```html
METADATEN
DARSTELLUNGSEBENE
```
Ein HTML-Dokument besteht aus zwei Teilen:
- ` ... ` – Metadaten für Browser, Suchmaschinen, Social Sharing
- ` ... ` – darzustellender Inhalt, Text, Formulare
---
# HTML Metadaten
```html
DHBW Stuttgart
...
```
*Webseiten besuchen nicht nur Menschen, sondern auch Suchmaschinen, Bots, Screen-Reader. Metadaten helfen beim "Verstehen" der Inhalte.*
---
# HTML Metadaten – Vertiefung
| Tag | Funktion |
|-----|----------|
| `` | Browser-Tab, Suchergebnis-Titel |
| ` ` | Zeichenkodierung (Umlaute!) |
| ` ` | Mobile Darstellung |
| ` ` | Suchergebnis-Snippet (max 160 Zeichen) |
**Open Graph** (Social-Media-Vorschau):
```html
```
→ Wirkt auf Mastodon, LinkedIn, Signal, Slack, MS Teams ...
**SEO:** Google nutzt `` + ` ` für Ranking + Snippet.
---
# HTML-Tags und Attribute

```html
Das ist ein wichtiger Absatz.
Das ist ein gewöhnlicher Absatz.
```
| Teil | Bezeichnung |
|------|-------------|
| `` | Opening Tag |
| `class="wichtig"` | Attribut |
| `Das ist ein wichtiger Absatz.` | Inhalt |
| `
` | Closing Tag |
---
# HTML-Tags und Attribute (selbst-schließend)

```html
Geburtsdatum
```
| Teil | Bezeichnung |
|------|-------------|
| ` ` | Schließendes `/` im (öffnenden) Tag |
---
# Vollständiges Grundgerüst

```html
Portfolio von ...
Hallo Welt!
Das ist mein erster Absatz.
```
---
# Die wichtigsten Tags
| Tag | Bedeutung |
|-----|-----------|
| `` … `` | Überschriften (h1 = größte) |
| ` ` | Absatz (Paragraph) |
| ` ... ` | Hyperlink |
| ` ` | Bild |
| `
`, ``, `` | Listen |
| `` | Container / Box |
| `
` | Inline-Container |
| ` ` | Eingabefeld |
Semantische Tags (``, ``, ``, ``, ``, ``) wichtig für Accessibility.
---
# Natives HTML
Was früher mit JavaScript gelöst wurde, kann HTML heute selbst. JS dafür einzusetzen ist heute oft ein **Code Smell**.
| Funktion | HTML-Element |
|----------|--------------|
| Aufklapp-Text | `` + `` |
| Popup / Modal | `` |
| Fortschrittsbalken | `` |
| Datum-Auswahl | ` ` |
| Validierung | Attribute: `required`, `min`, `max`, `pattern` |
---
# Beispiel: Details/Summary
*Akkordion · Accordion · Aufklappmenü · Collapsible*

```html
Klick mich!
Dieser Text ist versteckt.
```
Doku: [developer.mozilla.org](https://developer.mozilla.org/de/docs/Web/HTML/Reference/Elements/details)
---
# Beispiel: Details/Summary (geöffnet)

```html
Klick mich!
Dieser Text war versteckt.
```
---
# Beispiel: Button

```html
Add to favorites
```
Doku: [developer.mozilla.org](https://developer.mozilla.org/de/docs/Web/HTML/Reference/Elements/button)
---
# Beispiel: Input/Eingabefeld

```html
```
Doku: [developer.mozilla.org](https://developer.mozilla.org/de/docs/Web/HTML/Reference/Elements/input)
---
# Beispiel: Dialog
*Modal · Modales Fenster · Popup · Overlay · Dialogfenster*

```html
Greetings, one and all!
```
Doku: [developer.mozilla.org](https://developer.mozilla.org/de/docs/Web/HTML/Reference/Elements/dialog)
---
# CSS – Cascading Style Sheets
---
# Was ist CSS?
**C**ascading **S**tyle **S**heets
```css
p {
color: blue;
font-size: 16px;
}
```
- Trennt **Inhalt** (HTML) von **Darstellung** (CSS)
- "Cascading" = Regeln können überschrieben werden
- Eine CSS-Datei kann viele HTML-Seiten stylen
---
# CSS einbinden
**Option 1: Externe Datei** ✓
```html
```
**Option 2: Style-Tag**
```html
```
**Option 3: Inline** ✗
```html
...
```
→ Standard ist externe Datei. Inline vermeiden (schwer zu warten, keine Wiederverwendung).
---
# CSS-Anatomie

```css
selector {
property: value;
}
```
**Beispiel:**
```css
h1 {
color: #333333;
font-size: 2rem;
margin-bottom: 1rem;
}
```
Selektor → was wird gestylt
Property → welche Eigenschaft
Value → welcher Wert
---
# Selektoren: Element

```css
/* Alle -Elemente */
p {
color: gray;
}
/* Mehrere Elemente gleichzeitig */
h1, h2, h3 {
font-family: sans-serif;
}
```
Element-Selektoren sind die einfachsten. Komma = "oder".
---
# Selektoren: Klasse

```html
Dieser Text ist wichtig.
Dieser nicht.
```
```css
.wichtig {
color: red;
font-weight: bold;
}
```
**Punkt** vor dem Namen = Klasse. Beliebig oft anwendbar; ein Element kann mehrere Klassen haben.
---
# Selektoren: ID

```html
...
```
```css
#hauptnavigation {
background: #333;
padding: 1rem;
}
```
**Raute** vor dem Namen = ID.
⚠️ IDs sollten **einmalig** pro Seite sein. In der Praxis: Klassen meist besser.
---
# Selektoren: Kombinationen

```css
/* Nachfahre (beliebig tief verschachtelt) */
article p { line-height: 1.6; }
/* Direktes Kind (eine Ebene) */
nav > a { text-decoration: none; }
/* Nächstes Geschwister */
h2 + p { font-size: 1.2rem; }
/* Element mit Klasse */
p.wichtig { color: red; }
```
---
# Spezifität: Welche Regel gewinnt?

| Selektor | Spezifität |
|----------|------------|
| Element (`p`) | 0,0,0,1 |
| Klasse (`.wichtig`) | 0,0,1,0 |
| ID (`#header`) | 0,1,0,0 |
| Inline (`style="..."`) | 1,0,0,0 |
```css
p { color: blue; } /* 0,0,0,1 */
.text { color: green; } /* 0,0,1,0 → gewinnt */
#intro { color: red; } /* 0,1,0,0 → gewinnt über beide */
```
---
# CSS Spezifität – Vertiefung
| Selektor | Inline | IDs | Klassen | Elemente | Gesamt |
|----------|--------|-----|---------|----------|--------|
| `p` | 0 | 0 | 0 | 1 | 0,0,0,1 |
| `.info` | 0 | 0 | 1 | 0 | 0,0,1,0 |
| `p.info` | 0 | 0 | 1 | 1 | 0,0,1,1 |
| `#header` | 0 | 1 | 0 | 0 | 0,1,0,0 |
| `#header .nav a` | 0 | 1 | 1 | 1 | 0,1,1,1 |
**Regeln:**
- Eine Klasse (0,0,1,0) schlägt **jede Anzahl** Elemente (0,0,0,99)
- Eine ID schlägt jede Anzahl Klassen
- `!important` bricht alles → vermeiden
**Best Practice:** Flache Spezifität. BEM-Methodik (`.block__element--modifier`) hält sie niedrig.
---
# Box-Modell

Jedes HTML-Element ist eine rechteckige **Box**.
**Schichten innen → außen:**
- **content** – Inhalt (Text, Bild)
- **padding** – Innenabstand
- **border** – Rahmen
- **margin** – Außenabstand
Gesamt-Breite = `width + padding + border + margin`. Tipp: `box-sizing: border-box` rechnet padding + border mit ein.
---
# Box-Modell: CSS

```css
.box {
width: 200px;
height: 100px;
padding: 20px;
border: 2px solid black;
margin: 10px;
}
```
**Wichtig:**
```css
* {
box-sizing: border-box;
}
```
→ width/height inkludiert padding + border.
---
# Farben

```css
/* Keyword */
color: red;
color: rebeccapurple;
/* Hex */
color: #FF0000;
color: #F00;
/* RGB / RGBA */
color: rgb(255, 0, 0);
color: rgba(255, 0, 0, 0.5);
/* HSL */
color: hsl(0, 100%, 50%);
```
---
# Einheiten
| Einheit | Bedeutung |
|---------|-----------|
| `px` | Pixel (absolut) |
| `%` | Prozent vom Elternelement |
| `em` | Relativ zur Schriftgröße des Elements |
| `rem` | Relativ zur Schriftgröße des Root-Elements |
| `vw` / `vh` | Prozent der Viewport-Breite/-Höhe |
**Empfehlung:**
`rem` für Schrift, `%` oder `vw/vh` für Layout.
---
# Pseudo-Klassen

```css
/* Hover */
a:hover { color: red; }
/* Besuchter Link */
a:visited { color: purple; }
/* Fokussiertes Element */
input:focus { border-color: blue; }
/* Erstes/n-tes Kind */
li:first-child { font-weight: bold; }
li:nth-child(odd) { background: #eee; }
```
`:` vor dem Namen = Pseudo-Klasse.
---
# Pseudo-Elemente

```css
/* Vor dem Inhalt einfügen */
.required::before {
content: "* ";
color: red;
}
/* Erster Buchstabe */
p::first-letter {
font-size: 2em;
}
```
`::` = Pseudo-Element (erzeugt "virtuelles" Element)
`:` = Pseudo-Klasse (wählt existierendes Element im Zustand)
---
# Layout: Flexbox
```css
.container {
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
}
```
→ Eindimensionales Layout (Zeile *oder* Spalte). Tiefer in `02_css_extended`.
---
# Layout: Grid
```css
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
```
→ Zweidimensionales Layout (Zeilen *und* Spalten gleichzeitig).
---
# Responsive Design

```css
/* Mobile First: Basis-Styles */
.container {
padding: 1rem;
}
/* Ab 768px (Tablet) */
@media (min-width: 768px) {
.container { padding: 2rem; }
}
/* Ab 1024px (Desktop) */
@media (min-width: 1024px) {
.container { padding: 3rem; }
}
```
---
# Responsive Design – Vertiefung
**Mobile First** ist Standard: Basis-CSS für kleine Screens, dann Erweiterungen.
| Breakpoint | Gerät | Media Query |
|------------|-------|-------------|
| < 576px | Smartphone (Portrait) | Basis |
| ≥ 576px | Smartphone (Landscape) | `@media (min-width: 576px)` |
| ≥ 768px | Tablet | `@media (min-width: 768px)` |
| ≥ 992px | Desktop | `@media (min-width: 992px)` |
| ≥ 1200px | Large Desktop | `@media (min-width: 1200px)` |
**Viewport-Meta-Tag (kritisch!):**
```html
```
**Moderne Alternativen:** `clamp()`, Container Queries, CSS Grid `auto-fit`/`auto-fill`.
---
# JavaScript
---
# JavaScript Grundlagen
```javascript
// Variablen
let name = "Welt";
const alter = 25;
// Funktionen
function gruss(name) {
return `Hallo, ${name}!`;
}
// Arrow Functions
const add = (a, b) => a + b;
// Arrays
const arr = [1, 2, 3];
arr.map(x => x * 2); // [2, 4, 6]
```
---
# DOM Manipulation
```javascript
// Element auswählen
const title = document.querySelector('h1');
// Inhalt ändern
title.textContent = 'Neue Überschrift';
// Event Listener
button.addEventListener('click', () => {
alert('Geklickt!');
});
```
---
# Fetch API
```javascript
fetch('/api/products')
.then(res => res.json())
.then(data => {
console.log(data);
})
.catch(err => console.error(err));
```
---
# Async/Await
```javascript
async function loadProducts() {
try {
const res = await fetch('/api/products');
const data = await res.json();
return data;
} catch (err) {
console.error('Fehler:', err);
}
}
```
---

---
# Web Engineering Mandala
Interaktive version: [nextlevelshit.github.io/web-engineering-mandala](https://nextlevelshit.github.io/web-engineering-mandala/)
3 Schichten:
- **Core Layer** — JS, HTML, CSS (vanilla)
- **Build Layer** — bundlers, runtimes, template engines, pre/post processors
- **Application Layer** — frontend, backend, frameworks, SSR, CSS-utilities
3 Segmente: HTML (blau) · JavaScript (rot) · CSS (grün) · Mittelpunkt: `package.json`
---
# JavaScript Frameworks – Kategorien
| Kategorie | Beispiele |
|-----------|-----------|
| **CSS Frameworks** | Tailwind, Bootstrap, shadcn/ui |
| **Frontend Frameworks** | React, Vue, Svelte, Astro |
| **Rendering / Meta** | Next.js, Nuxt, Gatsby |
| **Build Tools / Bundler** | Webpack, Vite, Parcel, esbuild |
| **Backend Frameworks** | Express, Fastify, NestJS |
---
# Vanilla JS – Counter
```html
Clicked 0 times
```
✓ hohe Kompatibilität, simpel
✗ State-Management, Re-Rendering wird schnell komplex
---
# React – Counter (JSX)
```jsx
import { useState } from "react";
function MyButton() {
const [count, setCount] = useState(0);
return (
setCount(count + 1)}>
Clicked {count} times
);
}
```
- **Component-Based** Architecture
- **Virtual DOM**, JSX, Hooks
- großes Ökosystem (React Router, Redux, …)
---
# Vue 3 – Composition API
```vue
Clicked {{ count }} times
```
- **Reactive Data Binding**
- Single-File Components (`.vue`)
- Vue Router, Pinia (State)
---
# Svelte – Counter
```svelte
count += 1}>
Clicked {count} {count === 1 ? 'time' : 'times'}
```
- **Compiler-Based** – kein Runtime-Framework
- Reactive Assignments (`let`)
- Built-in Animationen
---
# Astro – Content-First
```astro
---
const greeting = "Hallo DHBW";
---
{greeting}
```
- **Islands Architecture** – Komponenten mehrerer Frameworks mischen
- Default: kein JS im Output (nur statisches HTML)
- Hydration on demand (`client:load`, `client:visible`)
---
# Rendering Frameworks
| | Frontend | SSR | SSG | File Routing |
|---|---|---|---|---|
| **Next.js** | React | ✓ | ✓ | `/app/page.js` |
| **Nuxt** | Vue | ✓ | ✓ | `/pages/*.vue` |
| **Gatsby** | React | – | ✓ | GraphQL Data |
---
# Build Tools – Webpack
- Module Bundling (JS, CSS, Images)
- Module Loaders + großes Plugin-Ökosystem
- Code Splitting, HMR
- Konfigurations-lastig (`webpack.config.js`)
→ Standard für viele Legacy-Setups.
---
# Build Tools – Vite
```javascript
// vite.config.js
import { defineConfig } from "vite";
export default defineConfig({
server: {
proxy: {
"/api": {
target: "http://localhost:4567",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, "")
}
}
}
});
```
- Rollup unter der Haube, **HMR mit ES Modules**
- Tree-Shaking, Code Splitting, React + Vue out-of-the-box
---
# Build Tools – Parcel
```json
{
"name": "my-project",
"source": "src/index.html",
"browserslist": "> 0.5%, last 2 versions, not dead",
"scripts": {
"start": "parcel",
"build": "parcel build"
},
"devDependencies": {
"parcel": "latest"
}
}
```
- **Zero-Config**
- Auto-Resolution, HMR
- TS / CSS-Preprocessors out-of-the-box
---
# Microfrontends
- Mehrere unabhängige Frontend-Apps in einer Page
- Module Federation (Webpack 5)
- **single-spa**: https://single-spa.js.org/
- Anwendungsfall: große Teams, unterschiedliche Tech-Stacks pro Domain
→ Komplexitätskosten: nur bei echtem Skalierungsbedarf.
---
# Demo-Repos
- https://github.com/nextlevelshit/dhbw-client-js (Counter, multi-framework)
- https://github.com/nextlevelshit/node-cache-api (API + Tests)
- https://github.com/nextlevelshit/dhbw-docker (Compose-Stack)