What is Malformed HTML?
Have you ever seen an HTML web page with error messages? Probably not but they can be on pages you visit on the World Wide Web everyday.
HTML tags can have errors. When they do we call it malformed HTML. When there are no errors we call it well formed HTML.
Often the errors are due to typing.
But they also can be improper usage. For example you are using the wrong tag attribute for the img
element file name or the file does not exist.
How Web Browsers Handle Malformed HTML
Web browser will attempt to render a readable web page that has HTML tag errors but does not show error messages.
Web browsers do not show HTML tags even if they malformed. Instead they well compensate by ignoring malformed HTML tags or "assume" the correct HTML tags in some cases.
This can lead to unpredictable results that vary between web browser and as you make modifications to your web page in the future.
Checking for Malformed HTML
You can check for malformed HTML using software available for free online. We often refer to this process as HTML validation or validating the HTML.
The W3C provides a free to use HTML validator service. We use it in the course.
Validation software error messages are not always clear, but they will pinpoint the line numbers in your file to look at. Often just looking at that line you will spot the problem.
A good rule of thumb is if you have many HTML errors is to fix the first one in the error list as the others many be a result of that one. In that case when the error is corrected others are also corrected.
You want to assure HTML tags are well formed. If your HTML is malformed you may find that one web browser shows the HTML document content as you intended and another may not be so forgiving.
Activity:
Based on your general experience searching for web pages and browsing web pages, describe the impact of malformed HTML using these questions.
-
Do you think users see malformed HTML errors in your HTML tags? Explain your answer.
Users do not see error messages from bad HTML syntax. They are more likely to experience a poor rendering of the content such as missing content, layout and styling. They may also experience problems with interactions such as clicking buttons or links.
-
Do you think malformed HTML will impact search engine software? Explain your answer.
Search engine software needs to know what is important in your content and identify items like the content title and a summary of its contents along with the important search keywords. Malformed HTML tags can hamper this process without your knowing.