Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 1 year ago

Blog Preview - HTML + CSS + media query

Adann Jacinto•790
@DanCodeCraft
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?

This is my second project, and I could figure it all out with little help.

I'm also very proud that I could think ahead and plan the project from beginning to end before starting to write my first line of code.

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

I wasn't sure how to make the project to fit a smaller screen (375px) and I opted to start from the desktop version.

I used media query to have the job done, and it worked perfectly.

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

I think I got everything right. However, I'm very open to criticism.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Grace•32,130
    @grace-snow
    Posted over 1 year ago

    I hope this feedback helps

    • think about the context of where this component would be used on a site. It is not a full Web page, just a single card component, likely to sit alongside other blog cards. That means it must not have a h1. The h1 element is for a page heading. This card would sit lower on a page, likely alongside similar cards, so should be a h2.
    • Alt text descriptions should not include words like "image" because it's on an element that already has an image role.
    • it's not an important thing for these challenges necessarily but becomes important on large projects much later. HTML head order really matters for performance! Harry Roberts has some recommendations about this but the main gist is that the title should be at the top straight after viewport meta and favicon last. This is a really minor thing but.i figure it doesn't hurt to mention it.
    • get into the habit of including a full modern css reset at the start of the styles in every project. Andy Bell has a good one you can look up and use.
    • Never write font size in px!. Not even once. Very important.
    • the card must not have a width. It should have a single max-width in rem. This ensures it can shrink narrower when it needs to and means the layout will work for people who change their default text size.
    • you can't have a hover style on a card unless the whole card is clickable. That means the interactive element inside the heading needs to fill the space of the card as explained in the inclusive components site
    • learning must not have a % width. Its extremely rare you'll use percentage widths at all to be honest. Instead learning should only use padding and the content to decide it's width.
    • there is no need for a media query in this challenge from what I can see. But for future reference media queries must be defined in rem or em not px; and you should almost always be working mobile first. That means mobile/smallest screen styles are the default, then override properties go in a min width media query. I've written a post all about these foundational principles
    Marked as helpful
  • Bálint Korpai•620
    @kemenyfa-szu
    Posted over 1 year ago

    Hi @DanCodeCraft!

    I like your solution and thanks again for checking out mine!

    One minor observation of mine:

    • On smaller screensizes, the illustration image should be cropped when the card is not wide enough to contain it.

    As you mentioned: "I wasn't sure how to make the project to fit a smaller screen (375px) and I opted to start from the desktop version."

    • You can do it by not using media queries as the layout does not change on different screensizes, only font-sizes get smaller on smaller screens, but it does not mean that your approach is not good. I am a big fan of intrinsic design and love to use the clamp, min and max functions especially the clamp function, where you define an absolute minimum, an absolute maximum with a fix unit and an ideal in-between value with a dynamic unit such as: clamp(1rem, 5vw, 2rem); Check out this workflow if you like the idea :)

    Keep up the awesome work :)

    Marked as helpful
  • Roraima Lugo González•510
    @roraima1986
    Posted over 1 year ago

    Congratulations on finishing the challenge. I like how it looks on you, keep practicing.

    Thanks to you, I realized that I didn't hover the shadow on the card, I've corrected it. 😅

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.

Frontend Mentor for Teams

Frontend Mentor for Teams helps companies and schools onboard and train developers through project-based learning. Our industry-standard projects give developers hands-on experience tackling real coding problems, helping them master their craft.

If you work in a company or are a student in a coding school, feel free to share Frontend Mentor for Teams with your manager or instructor, as they may use it to help with your coding education.

Learn more

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

Oops! 😬

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

Log in with GitHub