Explore foundational CSS knowledge to clarify common misconceptions and boost your frontend confidence. Perfect for refreshing your understanding of layout, selectors, and modern techniques.
What is the main difference between 'display: none' and 'visibility: hidden' when applied to an element in CSS?
Explanation: The correct answer highlights that 'display: none' removes the element from both layout and rendering, while 'visibility: hidden' makes it invisible but the space remains occupied. The second option ignores this crucial difference, the third confuses content types, and the fourth incorrectly links visibility to the DOM structure.
Between '.card .title' and '#card .title', which CSS selector has higher specificity?
Explanation: #card .title has higher specificity because IDs are more specific than classes. '.card .title' contains only class selectors, and 'They have equal specificity' is incorrect. The fourth option ignores how CSS resolves conflicts.
What does 'box-sizing: border-box' change about an element's sizing in CSS?
Explanation: 'box-sizing: border-box' means the total width and height include content, padding, and border, simplifying layout. The second option describes the default 'content-box', the third option misstates behavior, and the fourth understates what is included.
In a flex container, which property controls alignment of items along the main axis?
Explanation: 'justify-content' aligns items along the main axis. 'align-items' aligns along the cross axis, 'flex-direction' sets axis direction, and 'order' changes display order, not alignment.
What does 'grid-auto-flow: dense' do in a CSS Grid layout?
Explanation: With 'grid-auto-flow: dense', the grid tries to fill gaps in the layout by moving auto-placed items forward when possible. The other options are incorrect as they misrepresent gap-filling or grid structure behavior.
What is the default value of the 'position' property for most HTML elements?
Explanation: The default 'position' is 'static', meaning elements are positioned according to normal document flow. 'Relative', 'absolute', and 'fixed' must be set explicitly to change positioning context.
What does 'minmax(200px, 1fr)' mean when used in a CSS Grid template?
Explanation: 'minmax(200px, 1fr)' means the track is a minimum of 200px and can expand to a fraction of remaining space. The other options misunderstand minmax or incorrectly attribute interactivity or fixed size.
Why can a 'margin-top' on a first child element sometimes cause the parent element to move in CSS?
Explanation: Margin collapsing allows the parent and child's adjacent vertical margins to combine. The other options misstate how margins interact or imply doubling/ignoring which isn't accurate.
What is the effect of using 'clamp(16px, 2vw, 24px)' for font-size in CSS?
Explanation: 'clamp(16px, 2vw, 24px)' means the size scales with 2vw but is limited between 16px minimum and 24px maximum. The other choices ignore clamping behavior or limit scaling.
What key CSS properties are needed for 'text-overflow: ellipsis' to display an ellipsis?
Explanation: 'text-overflow: ellipsis' only works when an element is single-line, has a limited width, and has overflow hidden or clipped. The other options either ignore these requirements or add unrelated styling.