5 Mistakes in Html Code You Need To Avoid

5 Mistakes in Html Code You Need To Avoid

HTML stands for HyperText Markup Language which important in creating webpages and applications. HyperText means "Text within Text" which has a link within it. Whenever you click the hypertext it redirects you to that specified link. A Markup Language makes the text more responsive and dynamic. It's capable to change the hypertexts to images, tables, links, etc.

Below listed are some common HTML mistakes that can affect the whole structure of the website. Try to avoid the mistakes which are listed below-

1. Don't Forget to Use the ALT Attribute for Image Tags

The ALT attribute is very necessary for IMG tags, it works as a description for the context of the image. it is very helpful especially when your user is seeing the image but due to the slow connection it might not load, in this scenario, the ALT attribute will be showing on the image area which will help the user to identify whether the image is important to him or not. but if you are just using the image which is just for show, you can use an empty ALT attribute. Ex - alt="

  • Wrong ALT Attribute<img src="motivationalpic.jpeg"/>
  • Right ALT Attribute
  • <img src="motivationalpic" alt="Motivational pic to use"/>

2. Don't Use Unsupported Tags or Attributes

Don't use code that is not a part of HTML standards. There are certain attributes of HTML tags that might be recognized by some of the browsers but are not part of the HTML standards. Generally, improper attributes are used in the <body> tags that help in modifying the margin size. For making the website more user-friendly and compatibility we all must use at least HTML version 4.01. You can also check whether your page has any unsupported HTML tags or attributes by validating it at the W3C's HTML Validator

3. Remember To Put The DOCTYPE

The DOCTYPE helps the Web browsers to understand what kind of HTML is used by your page. If this is missing you will be not able to know whether your code is valid or not. The DOCTYPE should always be in the first line of your HTML Code, and it is also case sensitive. HTML 4.0 have three types of DOCTYPES -

  • a - HTML 4.01 Strict DTD (Document Type Definition)
  • b - HTML 4.01 Transitional DTD (Document Type Definition)
  • c - HTML 4.01 Frameset DTD (Document Type Definition)

4. Use of Paragraph 

It's not all recommended to use empty <p> elements just to add space in between paragraphs as it's very problematic for those people who use the screen-reading technology. As screen readers can announce the presence of the paragraph, but there will be no content in it to read.

It is recommended to use CSS properties like (margin) if any extra space is required, which will create the effect.

5. Avoid Using Multiple Line Breaks

The tag which we use for line break <br/> must be used for single-line breaks in the continuing paragraph text to shift the particular word down to a new line. You shouldn't use it to create gaps in between elements, instead of that you can divide the text into different paragraphs or simply you can adjust the margin style with the help of CSS.

Wrong:

Sample line

<br/>

<br/>

Sample line 2

Right:

<p> Sample line </p>

<p> Sample line 2 </p>

Thank you for reading the article. I hope it was well informed. In case you want any information regarding the omnichannel technologies, kindly contact us. Team WinSquares

will be happy to help you and make your work easier. It will be our immense pleasure if you give your valuable feedback in the comment section. Please share this article with your loved ones and professional circle if you like it

要查看或添加评论,请登录

社区洞察

其他会员也浏览了