What are the major points we need to follow in making html pages validated
In this tutorial you will learn how you can validate your webpage and what are the major mistakes you should avoid in writing the code.
As a beginner, there are lots of chances that you will make mistake in writing HTML code. Unsufficient knowledge of code strtucture will cause the page behave differently in each browsers.
To prevent this you will have to follow the guidelines and standards set by the W3C (Wide Web Consortium) for HTML web pages.
The World Wide Web Consortium provide a simple online tool (https://validator.w3.org/) where you can check you webpage’s validation. There are three ways of validating the webpages which are as follows.
1. Validate by URI
2. Validate by File Upload
3. Validate by Direct Input
What mistakes we should avoid:
1. Alt Tags
Most of the times, lots of developers forget to write the alt in img tag, if we do not write this tag, web page does not validate and it also affects your SEO.
Wrong Practise
<img src="images/logo.png" />
Correct Practise
<img src="images/logo.png" alt="Name" />
2. Element div not allowed as child of element span
We should always remember that we can not put element div inside the span elements, this always throws an error and it’s not a good practise.
Wrong Practise
<span><div></div></span>
Correct Practise
<div><span></span></div>
3. The type attribute is unnecessary for JavaScript resources
We should avoid using type=”text/script” for calling jquery codes because HTML5 doesn’t need this.
Wrong Practise
<script type='text/javascript' src='jquery.js></script>
Correct Practise
<script type='text/javascript' src='jquery.js></script>
Pitamber Singh
I am a passionate frontend developer with a solid foundation in React.js, Next.js, HTML5, CSS 3, WordPress, and JavaScript. My journey in web development has honed my skills in creating dynamic and visually appealing user interfaces. I excel in building scalable and efficient web applications with React.js, ensuring seamless user experiences.