div.box { width: 5rem; height: 5rem; margin: 0.5rem; } #box1 { background-color: red; display: inline-block; } #box2 { background-color: blue; display: inline-block; } #box3 { background-color: green; display: block; width: 100%; }
The red and blue boxes use display: inline-block;, so they appear side by side horizontally. The green box uses display: block;, so it takes the full width and appears below the inline-block boxes.
display property value causes an element to ignore its width and height settings and only take up as much space as its content?<span> that wrap tightly around their text.Elements with display: inline; ignore width and height properties and only take the space their content needs.
display: block;?Only option A uses an attribute selector to match elements with inline styles containing 'display: block'. Other options are invalid or do not select by display property.
display: contents; affect layout?display: contents; to a container element?display: contents; makes the container element itself disappear from the layout, but its children remain visible and act as if they are direct children of the container's parent.
display: none;?display: none; on elements regarding accessibility?Elements styled with display: none; are removed from the accessibility tree, so screen readers do not announce them. This is important to hide content both visually and from assistive technologies.