Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML HTML Tables Structuring Tables Add a Table Caption Element

Good practice for writing code

Just a really simple question here. When adding the code for a caption, is it best practice to put the code like this:

<caption>Employee Data</caption>

or like this:

  Employee Data

Is there a best practice guide here or is it just down to personal preference? I use WordPress as my main platform and know that they have several rules and regulations about how code should be written but I wondered if it went to this level.

Many thanks.

1 Answer

Luc de Brouwer
Luc de Brouwer
Full Stack JavaScript Techdegree Student 17,939 Points

Hi James,

If we are speaking of good practices and in this case the good practice of keeping your code organised it comes to personal preference. However there are a few things to keep in mind to make it easier to read for others. If you are using TAGs that require other tags nested inside that tag I would always recommend putting it like your second example.

If you are using self closing tags, like images or tags that don't require to be multi line I'd recommend putting it like your first example.

So let's say you'd have to make a nav bar which requires UL, LI, A tags then I'd say to use a format like this: the parent tag vertical, and small/short tags horizontal

 <li><a href="#">LI item</a></li>

Hi Luc

Yes, that's how I would do it so thanks for confirming what I thought.