
Design comparison
Community feedback
- @skyv26Posted 2 months ago
Hi @Abdallah-Darwesh, 👋
Your work shows promise, and with a few adjustments, it can be even more polished! Here are some specific suggestions to help refine your code and ensure best practices:
1️⃣ Semantic HTML Structure
Issue: Incorrect Heading Hierarchy
In your code:
<div class="content"> <h3>Learning</h3> <p>Published 21 Dec 2023</p> <h2>HTML & CSS foundations</h2> </div>
Why This Matters
Using
<h3>
above<h2>
breaks the heading hierarchy and can confuse screen readers or SEO crawlers. Think of it like writing a book: a chapter title (<h2>
) comes before its subheading (<h3>
).Suggested Fix
Update the structure so headings flow logically:
<div class="content"> <h2>Learning</h2> <p>Published 21 Dec 2023</p> <h3>HTML & CSS Foundations</h3> </div>
Real-Life Analogy: Imagine you’re reading a blog post. If the introduction (h2) comes after the subpoints (h3), wouldn’t it feel disorganized? Proper hierarchy ensures clarity for both readers and tools. 📖
2️⃣ Optimizing Centering Styles
Issue: Overcomplicated Centering
Your current approach uses multiple properties:
position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
Why This Matters
This method is verbose and harder to maintain. Modern CSS grid simplifies such tasks.
Suggested Fix
Use this streamlined approach:
body { display: grid; place-content: center; min-height: 100vh; }
Real-Life Analogy: Imagine aligning a picture on your wall. Would you measure everything manually, or use a centered frame with built-in guides? Grid is your built-in guide! 🖼️
3️⃣ Shadow Styling with
box-shadow
Issue: Inefficient Shadow Creation
Your code:
border-right: 7px solid black; border-bottom: 7px solid black;
Why This Matters
This method is visually inconsistent and increases the CSS file size.
Suggested Fix
Replace it with
box-shadow
:border: 1px solid black; box-shadow: 10px 10px 1px 1px black;
Real-Life Analogy: It’s like wrapping a gift—why use separate strips of tape when one wide strip does the job better? 🎁
4️⃣ Responsive Image Handling
Issue: Image Margins and Sizing
Current code unnecessarily adds margins and hardcoded widths:
.container > img, .content { width: 90%; margin: auto; }
Suggested Fix
Instead, use this:
.container > img, .content { width: 100%; border-radius: 10px; }
Real-Life Analogy: Think of resizing an image in a document. Setting it to "fit page width" works better than manually dragging corners every time! 🖼️
5️⃣ Style Simplification with
max-content
Issue: Hardcoded Width in
<h3>
Current code:
h3 { width: 100px; }
Suggested Fix
Use
width: max-content
for dynamic sizing:h3 { background-color: hsl(47, 88%, 63%); width: max-content; padding: 3px 0; border-radius: 5px; }
Real-Life Analogy: Imagine buying a shirt that adjusts to your size instead of guessing the perfect fit.
max-content
is like a tailored outfit for your text! 👕
6️⃣ CSS Efficiency and Best Practices
Issue: Repetitive Styles
Example:
.container > img, .content { width: 90%; margin: auto; } p { margin: 10px 0; color: hsl(0, 0%, 42%); font-size: 17px; }
Suggested Fix
Use classes or variables for shared styles:
.shared-styles { margin: 10px 0; color: hsl(0, 0%, 42%); font-size: 17px; } .container > img, .content { width: 100%; border-radius: 10px; }
Real-Life Analogy: It’s like reusing ingredients in recipes—why buy separate flour for every dish when one bag works for all? 🍞
A Friendly Note 🤗
It’s great that you’re coding and learning! However, remember to understand why you’re using a particular property instead of just copying. Tools like ChatGPT can brainstorm ideas, but the magic happens when you experiment and learn the "why" behind the code. ✨
- Fix heading hierarchy for better SEO and accessibility.
- Simplify centering with CSS grid.
- Use
box-shadow
for shadows. - Make images responsive with
width: 100%
. - Replace hardcoded widths with
max-content
. - Consolidate repetitive styles to improve efficiency.
Keep learning and growing! 🚀 Let me know if you have any questions! 😊
0
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