Design comparison
Solution retrospective
I couldn't make the Nutrition section exactly as the original design, any tips on how to do that please? It seems obviously simple but I'm not getting it.
Community feedback
- @StroudyPosted 2 months ago
Amazing job with this! You’re making fantastic progress. Here are some small tweaks that might take your solution to the next level…
-
Using a
<main>
tag inside the<body>
of your HTML is a best practice because it clearly identifies the main content of your page. This helps with accessibility and improves how search engines understand your content. -
Your heading elements
<h1><h3>
Missing<h2>
, Heading elements should be in sequentially-descending order (e.g.,<h1>
,<h2>
,<h3>
) to create a clear content structure, improving accessibility and SEO. Skipping levels or using them out of order can confuse screen readers, affect search engine rankings, and make your content harder to understand. -
While
px
is useful for precise, fixed sizing, such asborder-width
,border-radius
,inline-padding
, and<img>
sizes, it has limitations. Pixels don't scale well with user settings or adapt to different devices, which can negatively impact accessibility and responsiveness. For example, usingpx
for font sizes can make text harder to read on some screens, Check this article why font-size must NEVER be in pixels. In contrast, relative units likerem
and adjust based on the user’s preferences and device settings, making your design more flexible and accessible. Usepx
where exact sizing is needed, but prefer relative units for scalable layouts. If you want a deeper explanation watch this video by Kevin Powell CSS em and rem explained. Another great resource I found useful is this px to rem converter based on the default font-size of 16 pixel. -
Using a full modern CSS reset is beneficial because it removes default browser styling, creating a consistent starting point for your design across all browsers. It helps avoid unexpected layout issues and makes your styles more predictable, ensuring a uniform appearance on different devices and platforms, check out this site for a Full modern reset
-
I think you can benefit from using a naming convention like BEM (Block, Element, Modifier) is beneficial because it makes your CSS more organized, readable, and easier to maintain. BEM helps you clearly understand the purpose of each class, avoid naming conflicts, and create reusable components, leading to a more scalable codebase. For more details BEM,
You’re doing fantastic! I hope these tips help you as you continue your coding journey. Stay curious and keep experimenting—every challenge is an opportunity to learn. Have fun, and keep coding with confidence! 🌟
Marked as helpful0@bajwacodesPosted about 2 months ago@Stroudy
Thanks sir, I have done reading on everything pointed by you and try to not make same mistakes in next projects
1 -
- @MohammedOnGitPosted 2 months ago
Hello Uzair Bajwa!
Your recipe page layout is well-structured, but a few best practices can further enhance its readability, performance, and maintainability. Here’s what you should do:
-
In my opinion, after viewing the CSS file, the difficulty you are facing is a result of your excessive use of the margin property instead of padding. The margin property can sometimes blow your elements' layouts out of proportion and for that matter should be used with care.
-
Optimize Font Loading You're loading fonts multiple times from Google. Since both font links come from the same source, you can consolidate them into a single request to improve performance.
<link href="https://fonts.googleapis.com/css2?family=Young+Serif&family=Outfit:[email protected]&display=swap" rel="stylesheet">
- Use Heading Hierarchy Properly Ensure that the headings follow a logical hierarchy. For example, the title should be an <h1>, section titles should be <h2>, and any subsections can use <h3>. Currently, you’re using <h3> inside .prep where an <h2> would be better.
<h2>Preparation Time</h2>
- Avoid Redundant Code Your fonts are being linked twice; you can remove one of the duplicate <preconnect> statements:
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
- CSS and Class Naming Best Practices Follow naming conventions like BEM (Block, Element, Modifier) for your class names to make them more scalable and readable. For example:
<div class="nutrition__item"> <p class="nutrition__label">Calories</p> <span class="nutrition__value">277kcal</span> </div>
- Accessibility (a11y) Enhancements Use ARIA roles to improve the accessibility of the content. For instance, you can add a role to the ordered list of instructions to indicate it’s a recipe:
<ol role="list"> <li>...</li> </ol>
- Consider Lazy-loading Images For performance, you can add loading="lazy" to the image tag, especially if the page is image-heavy:
<img src="assets/images/image-omelette.jpeg" alt="delicious omelette in a plate" loading="lazy">
By following these best practices, your page will be more performant, maintainable, and accessible. You did great. keep it up!
Marked as helpful0@bajwacodesPosted about 2 months ago@Aggressive-Mohammed
Thanks for very useful tips sir, i am going to make sure i work on each of these pointed out properties in the next projects
0@bajwacodesPosted about 2 months ago@Aggressive-Mohammed
Thanks for very useful tips sir, i am going to make sure i work on each of these pointed out properties in the next projects
1 -
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