HTML5 Style Guide and Coding Conventions
HTML Coding Conventions
Web developers are frequently indeterminate about the coding style and linguistic structure to use in HTML.
In the vicinity of 2000 and 2010, many web developers changed over from HTML to XHTML.
With XHTML, developers were compelled to compose legitimate and "all around framed" code.
HTML5 is more messy with regards to code approval.
Use Correct Document Type
Use Lower Case Element Names
Bad:
<p>This is a paragraph.</p>
</SECTION>
Very Bad:
<p>This is a paragraph.</p>
</SECTION>
Good:
<p>This is a paragraph.</p>
</section>
Image Attributes
Bad:
Good:
Spaces and Equal Signs
Bad:
Good:
Omitting <head>?
In the HTML5 standard, the <head> tag can likewise be excluded.
Of course, programs will include all components previously <body>, to a default <head> component.
You can decrease the many-sided quality of HTML, by precluding the <head> tag:
Example
<!DOCTYPE html>
<html>
<title>Page Title</title>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
<html>
<title>Page Title</title>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Meta Data
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>HTML5 Syntax and Coding Style</title>
</head>
HTML Comments
Short comments should be written on one line, like this:
Comments that spans more than one line, should be written like this:
This is a long comment example. This is a long comment example.
This is a long comment example. This is a long comment example.
-->
Style Sheets
Use simple syntax for linking to style sheets (the type attribute is not necessary):
<link rel="stylesheet" href="styles.css">
Short rules can be written compressed, on one line, like this:
p.intro {font-family: Verdana; font-size: 16em;}
Long rules should be written over multiple lines:
body {
background-color: lightgrey;
font-family: "Arial Black", Helvetica, sans-serif;
font-size: 16em;
color: black;}
background-color: lightgrey;
font-family: "Arial Black", Helvetica, sans-serif;
font-size: 16em;
color: black;}








