Design comparison
Solution retrospective
Hello, I'm Steven and this is my solution for this challenge using SCSS and BEM!😊
🛠️ Built with:
- HTML 🧾
- Native CSS 🎨
- BEM Notation 🅱️
Thank you to the Front-End Mentor team that creates these challenges that help us learning journey to front-end.💟
I’m most proud of finding solutions to the problems I encountered. I figured out that the slight gap was due to the image element's default display: inline;
property, and the solution was to set the display to block
. I also used Lighthouse in Google DevTools for the first time to help with accessibility.
-
Unexpected Gap Issue:
There was a slight gap between my image and the bottomdiv
that wasn't due to padding or margin. I discovered this was because the image element has a defaultdisplay: inline;
property. The solution was to setdisplay: block
on the image to remove the gap. -
Accessibility Warning:
Using Lighthouse in Google DevTools, I received a warning that "Image elements do not have explicit width and height." After reading some documentation, I decided not to worry about performance improvements at this stage. -
Understanding
srcset
Behavior:
I initially had issues with thesrcset
attribute, as it lets the browser choo
There is still so much I don’t know, but I am learning more with every challenge. I would like to use Google DevTools more effectively to help me build in the future, but I don’t fully utilize it because I am unaware of all that it can offer. Any advice or guidance on using DevTools is highly welcome and encouraged.
Community feedback
- @grace-snowPosted 3 months ago
Great solution overall, you should be pleased with this.
Here are a few issues I noticed:
- the footer should be outside of main.
- try not to capitalise text in HTML. Use css to capitalise text if it’s a styling choice like this.
- look up how to write better alt text. There are some good posts in the resources channel on discord about this.
- you don't need to add aria-hidden on decorative images. Having the empty alt attribute is enough.
- I don't think the price should be in an
ins
element. It's just text, it's not been "inserted" like in a document highlighting edits. I'd expect a paragraph, either one containing both the current and old price or two paragraphs, with the old price wrapped in ans
ordel
(strictly speaking the strike through is more appropriate than delete). - try to think about the context of where this component would be used. It's a single product card. It is extremely unlikely it would act as the main heading for a whole page of content, and that tells you that this should not have a h1. Use a lower importance heading level.
- if a link opens in a new window like in that footer link, it needs to communicate that to screen readers either with some Sr only text in a span or via the title attribute on the link (eg "(opens in a new tab)").
- if you're gonna make the body a flex element it should have a column direction.
- get into the habit of including a full modern css reset at the start of the styles in every project.
- line height is usually unitless. It's not a problem it being in rem, just unusual and makes css longer.
- if you want to improve performance you can use the aspect ratio property on the img.
- it's better to define media queries in rem or em not px, so the layout can adjust well for all users including those who have a different text size.
- personally I would use grid and not flex on the component as its shorter to make it have two equal columns on larger screens.
Marked as helpful5@StroudyPosted 3 months ago@grace-snow Once again the wealth of knowledge you have is great, I can't express how grateful I am for your feedback and explanations. Thank you for pointing these out so I can look at them in more detail <3 Unbelievable member of the team/community.
1@StroudyPosted 3 months ago@grace-snow I have taken every bit of feedback you have given and made positive changes, I am always going to reference back to this for future projects. When I become a Frontend Developer I am going to speak highly of you.
Summary of Changes
-
Text Capitalization:
- Removed capitalized text in HTML and used
text-transform: uppercase;
in CSS.
- Removed capitalized text in HTML and used
-
Accessibility for Decorative Images:
- Removed
aria-hidden="true"
from decorative images and used an emptyalt=""
.
- Removed
-
Improved Alt Text:
- Reviewed and improved alt text based on best practices.
-
Corrected Price Markup:
- Changed
<ins>
to<p>
for the current price and used<s>
for the old price.
- Changed
-
Adjusted Heading Levels:
- Changed
<h1>
to<h2>
for the product card heading.
- Changed
-
Accessibility for Links:
- Added
title
attributes to links that open in new tabs (e.g.,title="(opens in a new tab)"
).
- Added
-
Flexbox Layout:
- Changed
flex-direction
tocolumn
on thebody
.
- Changed
-
Added CSS Reset:
- Included a full modern CSS reset at the start of the stylesheet.
-
Unitless Line Height:
- Made
line-height
unitless for better readability.
- Made
-
Aspect Ratio for Images:
- Used the
aspect-ratio
property for images.
- Used the
-
Media Query Units:
- Converted media queries from
px
torem
units for better responsiveness.
- Converted media queries from
2
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