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

Adding table

I am having trouble putting everything that I have learned together. I am endeavoring to add a table to a page after the header, and it is not working. What do I need to do to fix this? What are some good ways to put everything together?

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
    <title>Matt Bloomer| Designer</title>
      </head>
      <body>
        <header>

      <h1>Matt Bloomer</h1>  
      <h2>A great person! </h2>
        </a>
      <nav>
      <ul>
        <li><a href="index.html">intelligence</a></li>
        <li><a href="about.html">kind</a></li>
        <li><a href="hooka.html">funny</a></li>
        </ul>
      </nav>
    </header>
        <section>
        <p>This is my first website; I hope you like it.
          </p>
        </section>
      <table>
        <caption>My Life</caption>
        <thead>
      <tr>
        <th scope="col">Year</th>
        <th scope="col">Location</th>
        <th scope="col">Girlfriend</th>
        <th scope="col">Scool/Job</th>
        </tr>

      </thead>
        <tfoot>
          <tr>
          <td colspan="3">Strikes and gutters.</td>
          </tr>
        </tfoot>


      </table> 
     </body>
    <footer>
      <p>&copy; 2015 Matt Bloomer.</p>
        </footer>
      </html>

Hi Matt, I've wrapped your HTML in a code block so that folks can read your question more easily.

1 Answer

Before we get to the table, it is important to properly nest your HTML (and provide opening and closing tags where necessary). You've got an extra closing a tag and your footer is outside of the body.

          <h1>Matt Bloomer</h1>  
          <h2>A great person! </h2>
    </a><!-- you've got a closing a tag, but no opening tag. You might as well get rid of this -->
      </body>
      <footer>
        <p>&copy; 2015 Matt Bloomer.</p>
      </footer>
    </html>

With those corrections, your HTML should look something like this:

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <title>Matt Bloomer| Designer</title>
      </head>
      <body>
        <header>
          <h1>Matt Bloomer</h1>  
          <h2>A great person! </h2>
          <nav>
            <ul>
              <li><a href="index.html">intelligence</a></li>
              <li><a href="about.html">kind</a></li>
              <li><a href="hooka.html">funny</a></li>
            </ul>
          </nav>
        </header>

        <section>
          <p>This is my first website; I hope you like it.
          </p>
        </section>

        <table>
          <caption>My Life</caption>
          <thead>
            <tr>
              <th scope="col">Year</th>
              <th scope="col">Location</th>
              <th scope="col">Girlfriend</th>
              <th scope="col">Scool/Job</th>
            </tr>
          </thead>
          <tfoot>
            <tr>
              <td colspan="3">Strikes and gutters.</td>
            </tr>
          </tfoot>
        </table> 

        <footer>
          <p>&copy; 2015 Matt Bloomer.</p>
        </footer>
      </body>
    </html>

If you want to place the table right after the header with pure HTML, you'll need to add the table right after the header tags:

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <title>Matt Bloomer| Designer</title>
      </head>
      <body>

        <header>
          <h1>Matt Bloomer</h1>  
          <h2>A great person! </h2>
          <nav>
            <ul>
              <li><a href="index.html">intelligence</a></li>
              <li><a href="about.html">kind</a></li>
              <li><a href="hooka.html">funny</a></li>
            </ul>
          </nav>
        </header>

        <table>
          <caption>My Life</caption>
          <thead>
            <tr>
              <th scope="col">Year</th>
              <th scope="col">Location</th>
              <th scope="col">Girlfriend</th>
              <th scope="col">Scool/Job</th>
            </tr>
          </thead>
          <tfoot>
            <tr>
              <td colspan="3">Strikes and gutters.</td>
            </tr>
          </tfoot>
        </table> 

        <section>
          <p>This is my first website; I hope you like it.
          </p>
        </section>

        <footer>
          <p>&copy; 2015 Matt Bloomer.</p>
        </footer>

      </body>
    </html>

You can see a working copy of this at codepen.