DEV Community

Cover image for Mistakes To Avoid In Your HTML Code
Joseph Mania
Joseph Mania

Posted on • Originally published at

Mistakes To Avoid In Your HTML Code

The way you structure your HTML code will affect search engine optimization results. It’s always to use the right syntax while writing your code. HTML is not a programming language, hence you won’t get warnings about syntax errors. However, it will affect the general memory space and loading time.

Don’t forget the DOCTYPE

This word will give browser information on the version of HTML being employed. Your code might look invalid if the DOCTYPE is missing. The browser decides to make an assumption that will affect some tags. HTML online validator should be your tool to check the syntax loopholes.

Use a list while listing things rather than line breaks.

Of course, using
will output the same results, but it’s not a good practice. If you want to list items, just stick to using the ordered or unordered list.

  1. Mango
  2. Bananas

Avoid the use of and

The purpose of external CSS is to style up play the role of such tags. If it’s necessary, use the tag. But the best practice is to use the CSS font-weight and font style. They will perform a similar task but follow the correct semantics.

.Avoid using multiple line breaks

The work of line breaks is to knock the next word to the next line, Don’t make gaps using the
. If you need more space, adjust the margin style in the CSS file. Or you can use other tags like paragraph

Try your best to avoid inline styling
Kindly, if it’s not necessary, just avoid it. Create a class within the tag and style this in an external CSS. Inline CSS makes your code look bad and long. Remember, it might give the maintainer hard work while making some changes.

In modern site, don’t use the and tag

In the official latest release of HTML standard by W3C colostrum, the tags were not included, meaning they are outdated. Many users have considered them unimpressive and ugly. They also have side effects for some people with eye problems.

Don’t use any deprecated elements

This is where technology becomes challenging, you have to stay updated about it. Focus on the new and emphasized tags in the official latest release. After almost two years, the HTML community always releases a new version of their rules, so go through it.

Don’t forget to close any tags, especially the HTML

If you are using VS Code editor, it has autocompletion. But try your best to close the recommended tags. We have others like hr, br, and image which do not necessarily require closing. This can mess up your design. A clear check will help you avoid future errors that might be untraceable. You can decide to use the current indentation to align all the tags in a good manner, for visibility.

Neglecting comments

Please! Please! A good coder must always write his/her comments the right way. They will help in shortening your documentation. Writing a clear comment will give the maintainer a humble time while making some changes. It makes your code clean and you look professional. Also, in case of any mistake in the text, you will easily find the specific things you are searching for.

Don’t forget about the Alt attribute

This is one of the most common and worst mistakes designers forget. ALT attribute might look inferior, but if you understand its importance, you will never degrade it again. Have you ever loaded a page and an image fails to appear? The ALT text included in the image line will appear in that position. It tells the user what the image was all about. This will help the user to know if the image was of importance or not.

Discussion (0)