HTML
html-ind
Indent HTML using 2 spaces.
- Reason
- HTML tends to nest pretty deeply, and understandably so. Thus, a small indentation size works well in this case.
html-case
Use lowercase for HTML tags, attributes, and other identifiers.
- Reason
- Staying with all-lowercase for the code elements of HTML allows the actual content, which tends to be mixed-case, to stand out a little better among all of the tags and attributes. Content is king, after all.
html-attr
Don’t include whitespace before and after the
=
symbol in attributes.
- Reason
- Eliminating this whitespace helps attributes look like a more cohesive unit.
- Example
-
<div id="introduction" class="inset"> 1 + 1 = 3 is an interesting design principle pertaining to borders vs. whitespace. </div>
- Anti-Example
-
<div id = "introduction" class = "inset"> 1 + 1 = 3 is an interesting design principle pertaining to borders vs. whitespace. </div>
html-mvc
Be cognizant of deprecated HTML elements and attributes. Some of them are like that because they violate MVC.
- Reason
-
The modern view of HTML is that it holds the content or model of a particular web
application. Elements like
font
andcenter
or attributes such ascolor
pertain to the presentation or view, which today is rightly separated into CSS. - But They Still Work!
- Not surprisingly, the aforementioned elements (and more) are no longer part of HTML—but you might think they are because many web browsers still “forgive” their use. Accept no mercy.