HTML Style Guide And Code Structure

HTML Style Guide And Code Structure

Coding structure is important for the readability and maintenance of the program. While working on HTML we usually make some mistakes in the style and coding structure. We need to use the consistent style so that the code can easily understand by others. The code should be tidy and clean. In this blog, we will learn about the dos and don’ts of HTML of styling and coding.

Always declare the correct document type:

Document type should always declare at first before the <html> tag and always take care of lower and uppercase of the document type.



Use the elements name in lower case letters:

Lowercase letters are easier to write. Never mix lower case elements with upper case elements.

Close all HTML elements:

Close each and every HTML elements even empty HTML elements also.

There are some elements in which there are no closing tags.


Attributes name in lower case letters:

Attributes name should always be in lower case as it is easier to write and it looks clean and tidy.

Use quotes for the value of attributes:

There should be the use of quotation while defining the value of an attribute.

 Use the alt attribute with images:

As alt is used when the image is not getting loaded then whatever the text in alt attribute will show. So, alt attribute should always define with images.

No blank lines and indentation:

Indentation means a space left at the edge of a line of writing or the process of leaving a space. As much as space is left and blank lines are there in code when it is not needed then file size will increase and there will be problem SEO URL.

One should always keep above points in mind while working on HTML as it will be easier for you as well for others.

Thank You for your time.