Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

John Lundberg
John Lundberg
20,368 Points

The structure of a HTML document

Yesterday i took one of the courses in HTML and during lunch(took 5 minutes) i made a HTML document from memory and i would like the community to take a look if this is considered standard practice and if i forgot something? I have not researched anything during the time i wrote this.

I would like to know if i missunderstood the course or the elements thought?

<!DOCTYPE html> <!-- html declaration -->
    <head>
        <!-- Put scripts/css and title here-->
    </head>
    <body> <!-- Presentation Layer -->
        <div> <!-- Common practice to wrap the presentation layer in a div for structuring -->
        <header>
            <!-- Presentation/site header -->

            <nav> </nav> <!-- main navigation -->

        </header> 
        <main>
            <!-- The main presentation -->
            <section> 
                <!-- Common practice to wrap each elements in main with a section, for aid  -->
            </section>

            <article>
                <!-- for "articles" and small piceses of content -->
                <!--  optional to add  header and footer  in article for structure, do not wrap a main, main is reserved for the beeing directly in the body -->
                <!-- articles can also have sections for structuring the website -->
            </article>
        </main> 
        <aside>
            <!-- Content related to other sites or indirect information, for aid, can also be in other elements  -->
        </aside>

        <footer>
            <!-- the site footer, common practice for the lowest viewable section of the site --> 
        </footer>
        </div><!-- end of the body div --> 
    </body>
</html>

3 Answers

Ivan Penchev
Ivan Penchev
13,833 Points

HTML is pretty flexible, the idea of best practices is mainly for readability.

Here is a reference if you would like to read a little bit on code readability. https://code.tutsplus.com/tutorials/top-15-best-practices-for-writing-super-readable-code--net-8118

Ivan Penchev
Ivan Penchev
13,833 Points

It looks OK, other than that I have no idea what type of a feedback you are expecting, maybe you can nudge us toward your expectations?

P.S. for styling of code, be sure to check the Markdown Cheatsheet

John Lundberg
John Lundberg
20,368 Points

Thank you Ivan, I would like to know if i missunderstood the course or the elements thought.

Even if i did not it is always nice with some reasurance and besides you just thought me how to present code on the treehouse community. Much appreciated!

John Lundberg
John Lundberg
20,368 Points

How do i structure the content to be properly viewed on the forum?