W3 : character data is not allowed here html validation error

Error: Line 144, Column 6: character data is not allowed here

<div id="mydiv"></a>

This is the most common error message that once may receive while trying to validate their HTML page. The reasons that may cause this error,

  1. There might be some character's in your code that is not allowed.
  2. You might have some text in your html body that is not a part of any of the tags like div,span, p or any other.
  3. You might have forget to surround an attribute value with single or double quotes.
  4. If you are using HTML 4.01 doctype, make sure that you do not have any self closing tabs (/>) if yes then
  5. remove those slashes.

Note : Sometimes some unwanted characters may get added to your file (copy + paste file format issues) that may cause this issue, in such a case you must check that the file encoding format is UTF-8, if not just do that using Text-Editors like Notepad++ or SublimeText.

Try Out Code2care Dev Tools:


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.