Problem: Form Field Rhythm Enforcer

easy
15 min
Try to define a rhythm unit using CSS variables and apply it to form labels and inputs to maintain a uniform vertical rhythm in your forms.

Problem description

You have a simple form with multiple <label> and <input> pairs. Your task is to define a CSS custom property for a 2rem rhythm unit and apply it to the line-height and bottom margin of each <label> and <input>, ensuring consistent vertical spacing throughout the form.

Goal

Use only HTML and CSS to:

  1. Define --rhythm as 2rem in :root.

  2. Apply line-height: var(--rhythm); and margin-bottom: var(--rhythm); to all <label> and <input> elements.

Constraints

  • Only CSS is allowed.

  • Use rem units and CSS variables.

  • CSS file must be named styles.css.

  • Do not alter the HTML structure or add inline styles.

Sample visual output

Here’s what the output would look like:

Good luck trying the problem! If you’re unsure how to proceed, check the Solution.

Problem: Form Field Rhythm Enforcer

easy
15 min
Try to define a rhythm unit using CSS variables and apply it to form labels and inputs to maintain a uniform vertical rhythm in your forms.

Problem description

You have a simple form with multiple <label> and <input> pairs. Your task is to define a CSS custom property for a 2rem rhythm unit and apply it to the line-height and bottom margin of each <label> and <input>, ensuring consistent vertical spacing throughout the form.

Goal

Use only HTML and CSS to:

  1. Define --rhythm as 2rem in :root.

  2. Apply line-height: var(--rhythm); and margin-bottom: var(--rhythm); to all <label> and <input> elements.

Constraints

  • Only CSS is allowed.

  • Use rem units and CSS variables.

  • CSS file must be named styles.css.

  • Do not alter the HTML structure or add inline styles.

Sample visual output

Here’s what the output would look like:

Good luck trying the problem! If you’re unsure how to proceed, check the Solution.