Design comparison
Solution retrospective
Hello, This is my first challenge on Frontend Mentor.
I am having a bit of trouble regarding HTML semantics. For example, in this challenge would the name of the perfume be a <h1> or just <p>? As there is only one card in the challenge, I assumed it would be fine to make the title a <h1>, but what if there are multiple product cards on the page?
I am very interested in learning more about semantics, and when best to use certain tags, but am also interested in all potential feedback on my code as I have never received feedback on code before.
Thanks in advance
Community feedback
- @VCaramesPosted almost 2 years ago
Hey there! 👋 Here are some suggestions to help improve your code:
- Implement a "Mobile First" approach 📱 > 🖥
Mobile devices are now the dominant 👑 way in which people browse the web, it is critical that your website/content looks perfect on all mobile devices.
More Info: 📚
- For improved accessibility 📈 for your content, it is best practice to use
em
formedia-queries
. Using this unit gives users the ability to scale elements up and down, relative to a set value.
- The image’s
alt tag
description needs to be improved upon ⚠️. Assume that you are describing the image to a someone over the phone.
More Info:📚
https://www.w3.org/WAI/tutorials/images/
- This component requires the use of two images 🎑 at different breakpoints ⚠️. The
picture
element will facilitate this.
Here is an example of how it works: EXAMPLE
Syntax:
<picture> <source media="(min-width: )" srcset=""> <img src="" alt=""> </picture>
More Info:📚
https://www.w3schools.com/html/html_images_picture.asp
If you have any questions or need further clarification, feel free to reach out to me.
Happy Coding! 🎆🎊🪅
Marked as helpful1 - @MelvinAguilarPosted almost 2 years ago
Hi there 👋. Good job on completing the challenge !
I have some feedback for you if you want to improve your code.
If you have many components like this in your solution, you should consider changing your <h1> to <h2> and not to <p>, since the perfume's name can be considered the component's title, rather than another paragraph.
However, to maintain the page's main title, you can create an '<h1>' element within your 'main' element that will be hidden visually but visible and readable by screen readers. The class "sr-only" hides content visually and here are the styles to copy. e.g.:
<h1 class="sr-only">Product preview cards</h1>
Here are some suggestions:
- The
alt
attribute should not contain the words "image", "photo", or "picture", because the image tag already conveys that information.
If you want to learn more about the
alt
attribute, you can read this article.- The
aria-label
attribute works very well with interactive elements such as buttons or links, but with divs or <del> it usually causes problems, for example the "Previous price" text is not read by my screen reader.
- To avoid security issues you should use the
rel="noopener"
orrel="noreferrer"
attribute when you use thetarget="_blank"
attribute. This will prevent the new page from gain any kind of access to the original page. You can read more about this here.
I hope you find it useful! 😄 Above all, the solution you submitted is great!
Happy coding!
Marked as helpful1 - The
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