Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 5 months ago

i used flex to make the content responsive

Abdallah-Emad•20
@Abdallah-Darwesh
A solution to the Blog preview card challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)
Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Aakash Verma•9,500
    @skyv26
    Posted 5 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! 😊

Join 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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub