Validating email in php
Validating HTML for email can be tricky–read on for our how-to guide.
One of the most popular validators is the free one maintained by the W3C, or World Wide Web Consortium.
Errors are generally more critical than warnings, but sometimes errors can be ignored depending on context and usage.
Pay close attention to errors stating that a start tag or end tag have been omitted, or when an end tag has not finished.
HTML validators are invaluable tools for people that write code.
Use the results from the State of Email Production report to help benchmark your own process, identifying opportunities for improvement and using this evidence to make a compelling argument for more resources or process streamlining.
The validator will display errors for all types of standard tags and elements (TD, TR, TABLE, DIV, A, STRONG, etc.) All HTML elements should have an appropriate closing tag to be considered valid, and having valid (and properly nested) closing tags are critically important with HTML email.
However, there are a handful of elements that are considered empty elements or self-closing tags (namely BR and IMG in email).
HTML validators work best for email when you use them to check for syntax errors, unclosed tags, or orphaned tags. HTML validation works by comparing your HTML to a set of standards or rules, called a DOCTYPE.
When attempting to validate HTML coded for email with a web validator, it’s pretty common to see errors and warnings that are confusing. DOCTYPE is a document type declaration, and is usually placed at the beginning of your HTML file to tell the validator which set of standards to check your HTML against: In the case of web development, it also tells the browser which rendering mode to use.