Design comparison
Solution retrospective
For this challenge, I took a deep dive into web sustainability best practices for web fonts:
- Choosing between static and variable fonts
- Subsetting fonts to only include needed characters
- Converting font files to the most efficient formats
- Using the correct font-face declarations
- Preloading font files to improve page load performance
In future projects, I want to continue using what I learnt in this challenge and explore other web sustainability best practices.
What challenges did you encounter, and how did you overcome them?I dove deep into topics like font subsetting, converting font files, font-face declarations, and pre-loading font files. You can read about the choices I made and find links to the main resources I used in the README for this project.
What specific areas of your project would you like help with?I would appreciate feedback on the way I used web fonts, as this was my main focus for this project.
This is also my first challenge on Frontend Mentor. I want to make sure I got all the basics right and have a good foundation going forward.
Thanks for your help!
Community feedback
- @SabineEmdenPosted 4 months ago
Kagan MacTane is a web developer based in Brooklyn and San Francisco. He was so kind to give me a very thorough code review after I posted a link to my solution on Mastodon. Here are Kagan’s comments and my response.
Kagan: "I'm not sure the div inside the footer is necessary. You can just put the div's content directly into the footer tag if you want."
Before:
<footer> <div class="attribution"> Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank" >Frontend Mentor</a >. Coded by <a href="https://www.frontendmentor.io/profile/SabineEmden" >Sabine Emden</a >. </div> </footer>
.attribution { font-size: 0.6875rem; text-align: center; } .attribution a { color: hsl(228, 45%, 44%); }
I agree. The div inside the footer isn't necessary. It's there because it and the styling for its attribution class were part of the starter code. But there is no rule again replacing divs with semantic HTML tags. I'll remove the div and replace the class selector in the CSS with the element selector for the footer.
After:
<footer> Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank" >Frontend Mentor</a >. Coded by <a href="https://www.frontendmentor.io/profile/SabineEmden" >Sabine Emden</a >. </footer>
footer { font-size: 0.6875rem; text-align: center; } footer a { color: hsl(228, 45%, 44%); }
Kagan: "You've got some gnarly fractions going on in your font sizes. Maybe you could just set the base font size to be something a little larger or smaller, and then your decimals might be more like .5, .75, etc.? (Not sure; I haven't done the math on it and it might not be feasible.)"
Before:
body { ... font-size: 0.9375rem; ... } .card-qr-code h2 { font-size: 1.375; ... } footer { font-size: 0.6875rem; ... }
The font sizes are 15px (0.9375rem) for the paragraph, 22px (1.375rem) for the heading, and 11px (0.6875rem) for the footer. The fractions make the code less readable. It’s difficult to tell what the font sizes are without pulling out a calculator.
I can think of four possible solutions:
- Change the font sizes slightly to
1rem
(16px),1.5rem
(24px), and0.75rem
(12px). - Use the The 62.5% Font Size Trick and set the root font size to 62.5%, which is equivalent to 10px. This changes the font sizes in the design to
1.5rem
,2.2rem
, and1.1rem
. - Leave the font sizes in
rem
as they are and add comments with the sizes in pixel to the style sheet. - Use
calc()
to convert the font sizes.
I’m a hesitant to change the font sizes. I got the values for the font sizes from the style guide and the Figma files. The brief for the project is to “get it looking as close to the design as possible”, and the font sizes are part of the design.
I’ll go with the comments. They are the simplest option, stay true to the design, and will still work if the QR code component is used as part of a bigger project.
After:
body { ... /* 0.9375rem = 0.9375 * 16px = 15px */ font-size: 0.9375rem; ... } .card-qr-code h2 { /* 1.375rem = 1.375 * 16px = 22px */ font-size: 1.375rem; ... } footer { /* 0.6875rem = 0.6875 * 16px = 11px */ font-size: 0.6875rem; ... }
Kagan: "Also, I see you're using HSL colors. I'd like to know more about that decision (I'm more used to RGB). Were you advised to use HSL? Saw that in an article or course somewhere?"
I used HSL colors because that’s how the colors were given in the style guide for the project.
Kagan: "Also, just gotta say, and this is totally just my own pet peeve about spelling: there's a bunch of WOOF2 instead of WOFF2. It's just in documentation and obviously doesn't affect functionality at all, but it makes me twitch. Like I said, nitpicking!"
I totally agree! That needs to be changed. Thanks for pointing it out to me! That does not show attention to detail.
0 - Change the font sizes slightly to
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord