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

HTML + Vanilla CSS Recipe Page

NAHammell•10
@NAHammell
A solution to the Recipe page 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 pleased with the accuracy of the replication, in the future I would like to use more responsive typography.

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

The vanilla CSS became difficult to read when tweaking small things, I mitigated these difficulties by separating out a few styles but I need to learn a better way to organize my CSS in the future.

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

Are the semantics and organization of my HTML acceptable? If not, what could I do to improve it?

How could I organize my CSS better to prevent it turning into an unreadable mess?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Redened•40
    @Redened
    Posted about 1 year ago

    Your HTML looks very acceptable both in semantics and organization.

    Cant really think of anything other than putting all of your sections inside <main></main>

    So it would be like:

    <header>
        content
    </header>
    
    <main>
        <section>
            content
        </section>
    </main>
    

    Your CSS is a "bit" harder to read, though there are multiple ways to make it not so.

    First of all, consider moving your reset styles to a separate CSS file and then importing it into the main CSS file or linking separately into the HTML.

    With at least that you can no longer need to look at this when trying to focus.

    html {
        box-sizing: border-box;
        font-size: 16px;
    }
      
    *, *:before, *:after {
        box-sizing: border-box;
    }
      
    body, h1, h2, h3, h4, h5, h6, p, ol, ul {
        margin: 0;
        padding: 0;
        font-weight: normal;
    }
      
    ol, ul {
        list-style: none;
    }
      
    img {
        max-width: 100%;
        height: auto;
    }
    

    As for the rest of the code, I'm sure this is not the answer you want and it's probably not the best advice, but have you considered using SCSS or SASS instead of plain CSS ?

    They are pretty easy to learn and even if you use .scss/.sass files you can still write plain css into them and it works perfectly fine.

    Though using the special syntax they provide could probably make your code more readable.

    I'll provide an example here to give you an idea.

    This

    #nutrition-section table {
        width: 100%;
    }
    
    #nutrition-section caption {
        margin-bottom: 12px;
    }
    
    #nutrition-section table th {
        text-align: start;
    }
    
    #nutrition-section table th,
    #nutrition-section table td {
        width: 50%;
        padding: 12px;
        padding-left: 32px;
        border-bottom: 1px solid hsl(30, 18%, 87%);
    }
    
    #nutrition-section table tr:last-child th,
    #nutrition-section table tr:last-child td {
        border-bottom: none;
    }
    
    #nutrition-section table caption {
        text-align: start;
    }
    

    Could look like this

    #nutrition-section {
        table {
            width: 100%;
    
            caption {
                margin-bottom: 12px;
                text-align: start;
            }
    
            th {
                text-align: start;
            }
    
            th,
            td {
                width: 50%;
                padding: 12px;
                padding-left: 32px;
                border-bottom: 1px solid hsl(30, 18%, 87%);
            }
    
            tr:last-child th,
            tr:last-child td {
                border-bottom: none;
            }
        }
    }
    

    Though it does take some getting used to, there are a few benefits to using SCSS as you might see, such as, not repeating yourself 20 times over (#nutrition-section table - biggest offender).

    If we were to remove the properties and only leave selectors around.

    This

    #nutrition-section table { }
    
    #nutrition-section caption { }
    
    #nutrition-section table th { }
    
    #nutrition-section table th,
    #nutrition-section table td { }
    
    #nutrition-section table tr:last-child th,
    #nutrition-section table tr:last-child td { }
    
    #nutrition-section table caption { }
    

    Basically turns into this.

    #nutrition-section {
        table {
            caption { }
    
            th { }
    
            th,
            td { }
    
            tr:last-child th,
            tr:last-child td {}
        }
    }
    

    Reply to this comment if you'd like to know more.

    Cheers.

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.

Oops! 😬

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

Log in with GitHub