DEV Community

Srividya Mysore Venkatesh
Srividya Mysore Venkatesh

Posted on

Good HTML Practices

Over time just writing code holds very little value, that is because it is no more efficient, and loses modularity. Writing clean code becomes very essential.
Some good practices while writing HTML are listed below:

  1. Start with DOCTYPE
    DOCTYPE is required for activating standard mode.
    Bad: Good:
    <!DOCTYPE html>
    ...
    ...

  2. don't put white spaces around tags and attribute values.
    Bad:

    HTML Best Practices

Good:

HTML Best Practices

3.Don’t omit the closing tag
It is always a good practice to close all opened tags and in the same order.
Bad: Good:


... ...

4.Don’t mix character cases
Either have them written in UPPER case on in the lower case. It gives consistency also.
Bad:
General

Good:
General

Also Good:
General

5.Don’t mix tag for CSS and JavaScript
Sometimes script element blocks construction.
Bad:

Good:

Also good:

6.Use main element
main element can be used wrapping contents.Not use

everywhere.
Bad: ...

Good:

...

These practices make error rectification much easier and also helps with accessing elements easily

Top comments (2)

Collapse
 
kevinschweikert profile image
Kevin Schweikert

Your formatting is unfortunately not very readable. Maybe you want to look at the Markdown documentation: github.com/adam-p/markdown-here/wi...

Collapse
 
mysoresrividya profile image
Srividya Mysore Venkatesh

sure

Some comments may only be visible to logged-in visitors. Sign in to view all comments.