Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Blog preview card in HTML and CSS with Flexbox and Media queries

@JohnnyGuitar95

Desktop design screenshot for the Blog preview card coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


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

Proud of making markup and styling nearly as precise as in design

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

None

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

None

Community feedback

P

@Islandstone89

Posted

HTML:

  • Every webpage needs a <main> that wraps all of the content, except for <header> and footer>. This is vital for accessibility, as it helps screen readers identify the "main" section of a page. Replace <section> with <div class="card">, and wrap that in a <main>.

  • Do not use "image" in the alt text, as that will make screen readers announce "image" twice.

  • "Learning" is not a <button>, as it doesn't trigger an action. Make it a <p>.

  • Headings should always be in order, so you should never start with a <h5>. And "Published" is not a heading, so make it a <p>. Also, wrap the date in a <time> tag, like this:<p>Published <time datetime="2023-12-21">21 Dec 2023</time></p>.Read more about the <time> element here.

  • Change the profile image alt text to "Headshot of Gary Hooper" - this is more descriptive than just "Avatar".

  • "Greg Hooper" is a <p>, not a heading. If it were a heading, it would be a <h2>, as I mentioned the heading hierarchy above.

  • .attribution should be a <footer>, and you should use <p> for the text inside.

CSS:

  • Your CSS Reset is missing essential rules like max-width: 100% on <img>, to prevent images from overflowing their container. I like to use the reset from Andy Bell.

  • Add around 1rem of padding on the body, so the card doesn't touch the edges on small screens.

  • Remove the margin on the card.

  • To center the card horizontally and vertically, use Flexbox on the body:

display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100svh;
  • Remove width and height on "Learning". Give it a display: inline-block and some padding.

  • max-width on card should be in rem.

  • Remove the width and height on the card. Never limit the height of elements containing text!

  • Use 1.5 for line-height instead of 150%. You can set it on body, and the elements will inherit the value, there's no need to declare it on every element.

  • font-size must never be in px. This is a big accessibility issue, as it prevents the font size from scaling with the user's default setting in the browser. Use rem instead.

  • Media queries must be in rem, and it is common to do mobile styles as the default.

Marked as helpful

0

Please log in to post a comment

Log in with GitHub
Discord logo

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