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
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:
or like this:
<caption> Employee Data </caption>
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.
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
<ul> <li><a href="#">LI item</a></li> </ul>