Problem: Grid Gap Rhythm Layout
Problem description
You have a container element with class .grid that lays out child <h2> headings and <p> paragraphs in a two-column CSS Grid layout. Your task is to implement a consistent vertical rhythm by:
Defining a CSS custom property
--rhythmas1.5rem.Configuring the grid to have two equal columns and a row-gap equal to the rhythm unit.
Setting the
line-heightof all<h2>and<p>inside the grid to the rhythm unit.Removing default margins on those text elements so vertical spacing relies solely on the grid row-gap.
Goal
Use only HTML and CSS to:
Define
--rhythmas1.5remin:root.Apply
display: grid,grid-template-columns: repeat(2, 1fr)androw-gap: var(--rhythm)to the.gridcontainer.Set
line-height: var(--rhythm)andmargin: 0on.grid h2, .grid pso each text element aligns perfectly with the grid rows.
Constraints
Only CSS is allowed.
Use rem units and CSS variables.
CSS file must be named
styles.css.Do not modify the HTML structure or use JavaScript.
Rely on grid row-gap for spacing; do not use element margins for vertical spacing.
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: Grid Gap Rhythm Layout
Problem description
You have a container element with class .grid that lays out child <h2> headings and <p> paragraphs in a two-column CSS Grid layout. Your task is to implement a consistent vertical rhythm by:
Defining a CSS custom property
--rhythmas1.5rem.Configuring the grid to have two equal columns and a row-gap equal to the rhythm unit.
Setting the
line-heightof all<h2>and<p>inside the grid to the rhythm unit.Removing default margins on those text elements so vertical spacing relies solely on the grid row-gap.
Goal
Use only HTML and CSS to:
Define
--rhythmas1.5remin:root.Apply
display: grid,grid-template-columns: repeat(2, 1fr)androw-gap: var(--rhythm)to the.gridcontainer.Set
line-height: var(--rhythm)andmargin: 0on.grid h2, .grid pso each text element aligns perfectly with the grid rows.
Constraints
Only CSS is allowed.
Use rem units and CSS variables.
CSS file must be named
styles.css.Do not modify the HTML structure or use JavaScript.
Rely on grid row-gap for spacing; do not use element margins for vertical spacing.
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.