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

QR-code component using html and CSS

ZaiinabM 30

@ZaiinabM

Desktop design screenshot for the QR code component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hi guys, please checkout my solution/code and recommend or suggest ways to do better or properties I could use to make it look better . I had a few issues in getting the perfect size(height and width) of divs and also positioning the image and text in the divs. Thank you.

Community feedback

Ecem Gokdogan 9,380

@ecemgo

Posted

Some recommendations regarding your code that could be of interest to you.

In order to fix the accessibility issues:

  • You need to replace <div class="parent-container"> with the <main class="parent-container"> tag. You'd better use Semantic HTML, and you can also reach more information about it from Using Semantic HTML Tags Correctly.
  • Each main content needs to start with an h1 element. Your accessibility report states page should contain a level-one heading. So, you should use one <h1> element in the <main> tag. You can replace your <h3 class="heading">Improve your front-end skills by building projects</h3> element with the <h1 class="heading">Improve your front-end skills by building projects</h1> element.

After committing the changes on GitHub and you need to deploy it as a live site. Finally, you should click generate a new report on this solution page to clear the warnings.

Hope I am helpful. :)

Marked as helpful

0

ZaiinabM 30

@ZaiinabM

Posted

Will fix the errors and generate a new report. Thank you :) @ecemgo

1
Hassia Issah 50,670

@Hassiai

Posted

Replace <div class="parent-container"> with the main tag, <strong><h3 class="heading"> with <h1> to fix the accessibility issues. click here for more on web-accessibility and semantic html

Give h1 and p the same font-size of 15px which is 0.9375rem, text-align: center, the same margin-left, margin-right and margin-top values. Give p a margin bottom value.

For a responsive content,

  • Give .container a fixed max-width value and a padding value for all the sides max-width: 320px which is 20rem/em padding:16px which is 1rem/em
  • Give the img a max-width of 100% and a border-radius value, the rest are not needed.

There is no need to give the body a width value

To center .parent-container on the page using flexbox or grid,

  • USING FLEXBOX: add min-height:100vh; display: flex; align-items: center: justify-content: center; to the body
body{
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
  • USING GRID: Add min-height:100vh; display: grid place-items: center to the body
body{
min-height: 100vh;
display: grid;
place-items: center;
}

Use relative units like rem or em as unit for the padding, margin, width values and preferably rem for the font-size values, instead of using px which is an absolute unit. For more on CSS units Click here

Hope am helpful.

Well done for completing this challenge. HAPPY CODING

Marked as helpful

0

ZaiinabM 30

@ZaiinabM

Posted

Thank you for the resources! @Hassiai

0

@0xabdulkhaliq

Posted

Hello there 👋. Congratulations on successfully completing the challenge! 🎉

  • I have other recommendations regarding your code that I believe will be of great interest to you.

HTML 🏷️:

  • This solution generates accessibility error reports, "All page content should be contained by landmarks" is due to non-semantic markup, which causes lacking of landmark for a webpage
  • So fix it by replacing the <div class="parent-container"> element with the semantic element <main> in your index.html file to improve accessibility and organization of your page.
  • What is meant by landmark ?, They used to define major sections of your page instead of relying on generic elements like <div> or <span>. They are use to provide a more precise detail of the structure of our webpage to the browser or screen readers
  • For example:
    • The <main> element should include all content directly related to the page's main idea, so there should only be one per page
    • The <footer> typically contains information about the author of the section, copyright data or links to related documents.

HEADINGS ⚠️:

  • This solution has also generated accessibility error report due to lack of level-one heading <h1>
  • Every site must want at least one h1 element identifying and describing the main content of the page.
  • An h1 heading provides an important navigation point for users of assistive technologies, allowing them to easily find the main content of the page.
  • So we want to add a level-one heading to improve accessibility by reading aloud the heading by screen readers, you can achieve this by adding a sr-only class to hide it from visual users (it will be useful for visually impaired users).

CSS 🎨:

  • Looks like the component has not been centered correctly. So let me explain, How you can easily center the component without using margin or padding.
  • We don't need to use margin and padding to center the component both horizontally & vertically. Because using margin or padding will not dynamical centers our component at all states, Just add the following style rule
body {
    display: grid;
    place-items: center;
    min-height: 100vh
}
  • Now remove these styles, after removing you can able to see the changes
.parent-container {
   margin-top: 150px auto 100px;
}
  • Now your component has been properly centered

.

I hope you find this helpful 😄 Above all, the solution you submitted is great !

Happy coding!

Marked as helpful

0

ZaiinabM 30

@ZaiinabM

Posted

Thanks for the detailed explanation @0xAbdulKhalid

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