What is the difference between 'visibility:hidden' and 'display:none'?
Instruction: Explain the difference and use cases for 'visibility:hidden' and 'display:none'.
Context: This question evaluates the candidate's understanding of CSS properties that control the visibility and display of elements, and when to use each.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
display: none prevents an element and its descendants from generating layout boxes. The DOM nodes still exist. Removing those boxes usually changes surrounding layout. visibility: hidden keeps the element's layout space but suppresses its painting.
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS example</title> <style> .row { height: 30px; margin: 0; } .reserved { visibility: hidden; }...