HTML Code Styles

This is a follow-up post to one that I originally wrote in December 2012. Be sure to read it, as well!

Months ago, I wrote a post on some of my preferred HTML Code Styles during which I shared two specific things that I do whenever I am writing markup.

Specifically, I do the following things:

  1. Comment Terminating Tags
  2. Underscore Class Names

When it comes to writing code, there are always going to be standards – well, at least there should be – that depend on the proverbial sandbox in which we’re playing.

These standards will outline certain things that we should do, but there are always bound to be gray areas. Case in point: I know people have often commented (no pun intended) that they aren’t a fan of the way that I terminate certain closing blocks with comments such as // end if or // end while or // end class.

Which is completely fine – to me, that’s an example of a gray area that gives us, as developers, room for implementing our own unique styles. But then there are others that really should be reconsidered.

And that’s what I’ve had to do with some of my markup styles.

HTML Code Styles, Revisited

During the course of a developer’s career, there are going to be changes that are made in the tools that we use, in the strategies that we employ for designing and building software, and even in the way we write code.

Case in the point, I once wrote the following:

The second thing that I’m trying to implement on a more consistent basis is to use underscores rather than dashes to space out multiple words in ID’s and classnames.

This is because that when you opt to select the text, most IDE’s will only select the word leading up to the hyphen whereas if you use an underscore, then it will highlight the entire word.

But, to be honest, this choice was made for the sake for convenience rather than for the sake of good semantic conventions. And that’s a wrong reason for writing code in one style over the other.

Cool Story, Bro

I know, I know. There’s not really anything practical in this post other than simply sharing a convention that I’ve changed of my own.

Cool Story, Bro.

HTML Code Styles? Cool Story, Bro.

However, since it is something that I’ve discussed before and that I’ve changed during the course of my work, and since this blog has been (and will continue to be) more or less a showcase various things that I’ve worked on over the past few years, it seemed fitting to include it here.

Category:
Tips
Tags:

Join the conversation! 1 Comment

  1. It really gets on my nerves when you work with other dev’s that are too lazy to comment on terminating tags or worse….don’t indent their code!

Leave a Reply