Ten Principles For Clean HTML Code
Posted By : Rajan Rawat | 18-Apr-2018
Ten Principles For Clean HTML Code
HTML is base and the foundation of a webpage or website. Whenever I tell the developers about the CSS, I always tell them you should write the good HTML before the case. Because if the foundation is strong automatically the house will be strong. So always write the clean HTML code with the help of semantics.
Now I am going to share with you some important point that will help you to make your code clean and tidy
1. Use Strict DOCTYPE
Whenever i write my HTML code i always use <!DOCTYPE> declaration before HTML tag. <!DOCTYPE> is not a HTML tag but i will help the browser to detect HTML version that written in the code
2. Encoding characters & Character set
In our <head> we use the character set UTF-8 and this first we must declare in out web-page, but this is declared after the title. Because with the help of this our browser detects any funny character if we use in the web-page
3. Indentation should be proper
Many of the developers are not aware of coding style and the syntax of
4. JavaScript and CSS must be external
Always import youCss and javascript file externally
<link href="mystyle.css" rel="stylesheet" type="text/css">
5. Always nest your tags properly
As the per the norms always make your clean and nest your tags proper make the code like that, so it is easy to understand the other developers where the tag is starting and where the tag is closing
6. Eliminate all the unnecessary divs in code
Most of the developers wrap the Underorder list in the div tag which makes no sense. My opinions
7. Better naming conventions for classes and id
Always use the classes which relevant to the element or easy to recognize like for
8. Do the typography always in CSS
Typography means like if you change the case text "home" use CSS
9. Validation
Whenever you are the writing the code make
10. Classes and id
Always write the CSS the use the parent class or id to make easy to understand make the CSS unique for every element
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Rajan Rawat
Rajan is a UI Developer, having good knowledge of HTML, CSS and javascript. His hobbies are internet surfing and watching sports.