Jedes Element hat ein standardmäßiges display-Verhalten, das steuert, wie es im Layout angeordnet wird.
<div>, <p>, <h1>, <section>, <ul>.<span>, <a>, <strong>, <em>.<p>This is a <strong>bold</strong> word inside a paragraph.</p>
<!-- <strong> stays inline; the two <div>s below stack vertically -->
<div>Block one</div>
<div>Block two</div>
span { width: 200px; height: 50px; } /* ❌ ignored — span is inline */
Das Setzen von width/height auf ein Inline-Element hat keine Wirkung. Die Lösung ist, sein display zu ändern:
span { display: inline-block; width: 200px; } /* ✅ flows inline BUT respects size */
inline-block sitzt im Textfluss (nebeneinander) und berücksichtigt width/height/margins – perfekt für Navigationselemente, Badges oder Schaltflächen, die in einer Reihe angeordnet sind.
block → new line, full width, sizeable
inline → in-line, content width, NOT sizeable (vertically)
inline-block → in-line, content flow, sizeable
Das Verständnis des standardmäßigen display erklärt, warum dein <span> keine Höhe annimmt, warum <div>s sich stapeln, und wann du zu inline-block, flex oder grid wechseln solltest.
Es ist die Grundlage, wie Elemente angeordnet werden, bevor du ein Layout-System anwendest.