הצגה והסתרה (תצוגה)
עמוד זה דורש דפדפן עדכני (תומך ב-SharedArrayBuffer). אנא עדכן את Chrome, Edge, Firefox או Safari לגרסה העדכנית ביותר.
English
How boxes flow
- Some elements are block: they stack on top of each other and fill the width —
<div>,<p>,<h1>. - Some are inline: they sit side by side, taking only as much room as they need —
<span>,<a>,<strong>. displaylets you change which way an element behaves.
English
display: none
display: none;removes an element from the page completely.- It's how menus, pop-ups, and "read more" sections stay hidden until needed.
- The element is still in your HTML — it just isn't shown.
display: blockchanges the other way: below, an inline<span>gets a whole line of its own, and its background fills the width.
English
<style>
.pill { display: block; background-color: #def; padding: 6px; }
.gone { display: none; }
</style>
<span class="pill">A span, now a block</span>
<span class="gone">You can't see me</span>
English
Common mistakes
display: noneremoves the element and its space;visibility: hiddenkeeps its space.blockstarts a new line;inlinedoes not.
English
Now you try
display: nonehides;display: blockmakes an element take its own line.- Hide one element, then change how another displays.
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
הסתר את ההודעה הסתרייה. הוסף .secret { display: none; }.
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
הפוך כל תווית לשורה נפרדת. הוסף .label { display: block; }.
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
פריטי רשימה עומדים זה על גבי זה כי <li> הוא בלוק. הנח את התפריט בשורה אחת עם li { display: inline; }.