Internet
Fact-checked

At WiseGEEK, we're committed to delivering accurate, trustworthy information. Our expert-authored content is rigorously fact-checked and sourced from credible authorities. Discover how we uphold the highest standards in providing you with reliable knowledge.

Learn more...

What Are the Best Tips for HTML Formatting?

Angela Farrer
Angela Farrer

The best tips for hypertext markup language (HTML) formatting include specifying a document type declaration, adding good metadata keywords for better search engine optimization (SEO), and following a consistent system of indentation to make HTML formatting easier for others to read. Writing good HTML code also entails following a set of rules for nesting tags in the correct order, which sometimes takes some extra attention to detail. Adding specific comments throughout an HTML document is an additional good formatting tip that streamlines the editing process. Learning good HTML formatting is usually considered a fundamental part of the web design process.

HTML coding in a new document often begins with a declaration that indicates which type of HTML tags will be used in the document. The three most common document type declarations are called HTML Strict, HTML Transitional, and HTML Frameset. Including one of these declarations is essential for checking an HTML document with a validation tool that is designed to check for coding errors.

When working with HTML code, it's important to include closed tags.
When working with HTML code, it's important to include closed tags.

Many professional web developers recommend using the HTML Strict declaration whenever possible. The HTML Transitional document declaration can be used in cases when the web designer uses elements from different versions of HTML. An example would be a document written mostly in HTML 4 with a few added features coded in HTML 5.

Metadata keywords are one of the most important elements of a website that will rank well in major search engines. These keywords are also one area of HTML formatting that many web designers overlook or fail to plan thoroughly enough. Inserting specific and relevant keywords in the metadata tags often makes a significant difference in bringing targeted visitors to a site based on similar phrases that they type into a search engine.

Many web developers recommend using the HTML Strict declaration whenever possible.
Many web developers recommend using the HTML Strict declaration whenever possible.

A common HTML formatting mistake for beginning web developers is to keep every line of code left-justified in their HTML editors. While this practice saves time in indenting HTML elements, it results in HTML documents that are difficult to decipher. Incorrect indentation can also sometimes lead to inaccurate editing when other designers check an HTML document for mistakes, and these missed errors can even cause a web page to render incorrectly in a browser. A general rule for indentation is that only opening and closing tags should be left-justified with their HTML contents indented with at least one tab space.

The best tips for hypertext markup language (HTML) formatting include specifying a document type declaration, adding good metadata keywords and following a consistent system of indentation.
The best tips for hypertext markup language (HTML) formatting include specifying a document type declaration, adding good metadata keywords and following a consistent system of indentation.

Proper tag nesting is also essential for correct HTML formatting. Closing tags of a line of HTML code generally need to be typed in the same logical order as their corresponding opening tags. This formatting step often takes some practice with lines of HTML code that contain several nested elements.

Discuss this Article

Post your comments
Login:
Forgot password?
Register:
    • When working with HTML code, it's important to include closed tags.
      By: Alexstar
      When working with HTML code, it's important to include closed tags.
    • Many web developers recommend using the HTML Strict declaration whenever possible.
      By: Monkey Business
      Many web developers recommend using the HTML Strict declaration whenever possible.
    • The best tips for hypertext markup language (HTML) formatting include specifying a document type declaration, adding good metadata keywords and following a consistent system of indentation.
      By: spaxiax
      The best tips for hypertext markup language (HTML) formatting include specifying a document type declaration, adding good metadata keywords and following a consistent system of indentation.