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!

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 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.