Problem: Fluid Typography with CSS Container Queries
Problem description
Given a .card element with a heading (<h2>) and paragraph (<p>), write CSS rules to:
Enable container query on
.cardby settingcontainer-type: inline-size.Define fluid font sizes inside a container query for container widths between
300pxand800px:<h2>scales from20px(min) to32px(max) usingclamp().<p>scales from14px(min) to18px(max) usingclamp().
Provide a fallback using
@supports not (container-type: inline-size)to apply static font sizes:<h2>at20px<p>at14px.
Goal
Demonstrate advanced fluid typography techniques by adapting text size based on container width with graceful degradation for legacy browsers.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support modern browsers with CSS Container Queries and fallback in others.
Container width range should be from
300pxto800px.Static fallback sizes should be as follows:
<h2>20pxand<p>14px.
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: Fluid Typography with CSS Container Queries
Problem description
Given a .card element with a heading (<h2>) and paragraph (<p>), write CSS rules to:
Enable container query on
.cardby settingcontainer-type: inline-size.Define fluid font sizes inside a container query for container widths between
300pxand800px:<h2>scales from20px(min) to32px(max) usingclamp().<p>scales from14px(min) to18px(max) usingclamp().
Provide a fallback using
@supports not (container-type: inline-size)to apply static font sizes:<h2>at20px<p>at14px.
Goal
Demonstrate advanced fluid typography techniques by adapting text size based on container width with graceful degradation for legacy browsers.
Constraints
The solution must use an external stylesheet named
styles.css.Do not use JavaScript.
Support modern browsers with CSS Container Queries and fallback in others.
Container width range should be from
300pxto800px.Static fallback sizes should be as follows:
<h2>20pxand<p>14px.
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.