Display & Visibility in CSS

From the CSS cheat sheet ยท Display & Visibility ยท verified Jul 2026

Display & Visibility

Block, inline, none, visibility, and opacity

css
display: block;        /* Full width, new line */
display: inline;       /* Flows with text */
display: inline-block; /* Inline but accepts width/height */
display: none;         /* Removed from layout */
display: flex;         /* Flexbox container */
display: grid;         /* Grid container */

visibility: hidden;    /* Hidden but takes up space */
opacity: 0;            /* Transparent but interactive */
๐Ÿ’ก display: none removes from layout AND accessibility โ€” use .sr-only to hide visually but keep for screen readers
โšก object-fit: cover on images is like background-size: cover but for img/video elements
๐Ÿ“Œ inline elements ignore width, height, and vertical margin โ€” use inline-block if you need those
๐ŸŸข See the CSS Flexbox and CSS Grid sheets for complete layout system references
displayvisibilityhide

More CSS tasks

Back to the full CSS cheat sheet