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

Blog preview page with CSS box model and flexbox

NeonCodes•60
@NeonCodes
A solution to the Blog preview card challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

I am proud that the final result looks close to the image preview. It was also another opportunity to continue practicing flexbox and try hover and focus states. Next time, I hope I will code faster and make less research.

What challenges did you encounter, and how did you overcome them?

-Styling the two images: put each image in a div image 1 and 2 : at first, the first image didn t have round corners despite applying border-radius ; putting it directly in img{} fixed that at first ; Then, adding padding to image erased border-radius again. = adding padding to card instead of image fixed that.

-The yellow background kept getting inside the card: I changed yellow background to html {} instead of inside *

-  Sometimes, It was easy to get lost in all the divs and containers. I had to review my code and the indents multiple times to make sure everything was okay.

-The second image doesn’t keep its size inside the div:did styling on the head instead of the css stylesheet to fix that.

What specific areas of your project would you like help with?

I need help positioning authorname correctly: It was positioned fine on a previous version then, I changed the font and couldn't get the same result. I can't find it in the repository either. Also, general feedback on the code itself is welcome: organization, unnecessary lines, things that could have been done more easily etc

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Teodor Jenkler•4,040
    @TedJenkler
    Posted 11 months ago

    Hi @NeonCodes,

    Nice project! Here are a few suggestions:

    For this project, an ideal structure would be to use <main> and <footer>. Set <main> as a flex container with flex-direction: column so that all elements stack on top of each other. This will help you remove unnecessary <div>s and incorrect semantics, such as <header>.

    Consider this analogy for HTML and CSS: imagine HTML as Lego bricks and CSS as the color you apply to those bricks. Instead of changing the color by altering the brick itself, choose the right brick and then apply the appropriate color. It might sound like a silly analogy, but it can be helpful. The <h1> tag should be reserved for the most important content, like the page title. For this project, <h1> is not needed. Instead, use <h2> for main headings, and within <h2>, use <h3>, and so on, with <h4> for sub-sub-headings. This approach will greatly improve accessibility, SEO, and overall readability.

    Keep up the great work!

    Best, Teodor

    Marked as helpful
  • Yassine•50
    @xYAssixx
    Posted 11 months ago
    • The solution includes semantic HTML , and that is a good start.
    • The code is not accessible because it needs reordering semantic HTML5 elements
    • There are some improvements that can be made:
    1. you don't need to use img elements inside div , only if you need to use pseudo elements like before
    2. to fix author section you just have to set author to flex box with no specific width
    3. you need to reorder semantic HTML , so that all elements are inside the body element. :
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Sample Semantic HTML Page</title>
    </head>
    <body>
    
        <header>
            <h1>Website Title</h1>
            <p>Welcome to our website</p>
        </header>
    
        <section>
            <article>
                <h2>Article Title</h2>
                <p>This is a sample article about something interesting.</p>
            </article>
        </section>
    
        <footer>
            <p>© 2024 Website Name. All Rights Reserved.</p>
        </footer>
    
    </body>
    </html>
    
    Marked as helpful

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

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

Oops! 😬

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

Log in with GitHub