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

News homepage - Sass, BEM, Mobile first, accessible mobile navigation

accessibility, bem, sass/scss
tediko•6,700
@tediko
A solution to the News homepage challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Hello! 👋

The design of this project caught my attention, so I decided to do it. It was a great opportunity to learn Sass CSS pre-processor and implement it into this project. I tried to create accessible mobile navigation by following Web Accessibility Guidelines. Just like in other recent projects i used mobile-first approach.

💡Here's some new things I used or learned:

  • Learned Sass CSS pre-processor. Sass is a stylesheet language that’s compiled to CSS. It allows to use variables, nested rules, mixins, functions, and more, all with a fully CSS-compatible syntax. Sass helps keep large stylesheets well-organized and makes it easy to share design within and across projects.
  • Used Sass file structure called 7-1 Pattern. It offers great way to modularize Sass file structure and help keep things easier to maintain. It's all about having everything in order so it is easier to work with code.
  • Followed Web Accessibility Guidelines v1.0 to make accessible mobile navigation
  • Used CSS Counters to automatically number the articles in trending section. CSS counters let you adjust the appearance of content based on its location in a document. For example, you can use counters to automatically number the headings in a webpage, or to change the numbering on ordered lists.

🛠️Build with: (can be found also in my others projects)

  • I used simple container as a proxy JavaScript technique to make entire container clickable in situations where container acts like illustrated introduction to article and it has a link inside (see articles or trending sections). One drawback was that by creating the entire container clickable, user will not be able to select anything.To allow selecting I detected how long the user is taking between mousedown and mouseup events and suppress the clicking event if user is likely to be selecting text.
  • CSS backdrop-filter property for overlay when the modal pops up. The backdrop-filter property is used to apply a graphical effect to the area behind an element. I used it to blur the page behind my overlay.
  • <picture> HTML element for responsive images. That is images that work well on devices with widely differing screen size. HTML provides us with elements to display identical image content, just larger or smaller depending on the device. This helps to improve performance across different devices.
  • Reduced browser inconsistencies in things like default line heights, margins and font sizes of headings, and so on by using CSS Reset by Andy Bell
  • BEM - Block, Element, Modifier methodology, which is a popular naming convention for classes in HTML and CSS. BEM is useful when it comes to larger, more complex projects when code organization becomes crucial. The idea behind it is to speed up the development process, and ease the teamwork of developers by arranging CSS classes into independent modules.
  • mobile-first approach. It is one of the best strategies to create either a responsive or adaptive design. Started with the smallest mobile screen and worked my way up.
  • :focus-visible pseudo-class to increase usability for sighted users who use keyboard navigation. The :focus-visible pseudo-class is a native CSS way to style elements that are in focus but only applies when you actually want a visual indicator to help the user see where the focus is.
  • Instead of repeating code for reusable elements I write some helper classes to reuse them throughout the project. I created reusable classes for headings, paragraphs or containers. This saves time as well as unnecessary code repetition. I will definitely try to improve in this aspect.

❓Questions:

  • No specific questions. Any suggestions on how I can improve are welcome!
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

    Here's some feedback

    1. You must change the aria label on that logo link. It must say name of the site and then destination e.g. W News - Home. Links already have a navigation role, never write verbose labels like "navigate to..."
    2. Similarly, the label on the nav toggle should say "Navigation toggle" or "menu toggle" not "Open X" and the label text should not change on click. Think about how this will be exposed to the accessibility API. It would currently be announced as "Open menu, Collapsed" or "Close menu, Expanded". That sounds kind of confusing when you compare to "Menu toggle, Collapsed/Expanded" doesn't it.
    3. Similar again, the label on the nav element doesn't need to include the word "navigation". It's already a nav! So just "main" or "primary" is fine
    4. Think through the page semantics without any styling. "The Bright Future of Web 3.0" is definitely not the page heading. This needs a visually hidden h1. Personally, I would make all article titles h3s in this and make sure appropriate visually-hidden h1 and in places h2s are added when needed. For example: h1 = "News Homepage"; h2 = "Featured"; h3 = "The bright future..."; h2 = "New"; h3s = The article titles in that section; h2 = "Most Read"; h3 = The articles within that section.
    5. This would benefit from using CSS grid for the main layout;
    6. I would expect the media query in the picture element to be defined in rem or em, just like the CSS. Not strictly necessary, just what I would do.
    7. Do you think all of the images are decorative on this?? I'd expect news article images to be considered meaningful content, at lease all except the abstract one.... Something to consider anyway. Not something you definitely need to change.
    8. The last section is clearly an ordered list so that's what it should be using in the html. (Not unordered)
    9. Text should never be in spans. I'd expect those numbers either to be paragraphs or pseudo content using the list counter.
    Marked as helpful
  • P
    Maisha Mir•190
    @maishamir
    Posted over 1 year ago

    Wow that's spot on! How'd you make it so exact to the design? Only thing I noticed was that the background color is slightly different, but that might just be a design choice.

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 1st-party linked stylesheets, and styles within <style> tags.

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.

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