When you create an HTML page, it should be verified against the W3C validator to make sure about the formatting according to the standards.
Here are a few standards.
As per Empty Elements guides from w3c, all elements must be properly closed.
For self-closing tags such as br and hr, add EXACTLY ONE space before the forward slash (/) and close them.
HTML standards require to write all tags and attributes of those tags in lowercase.
Regarding the attributes values, write them if they are just going to be used for machines but if the data is going to be human readable then write it with proper capitalization.
According to w3c HTML standards, all attribute values must be quoted, even the numeric ones.
You can get away with the incorrect HTML code but that might lead to security vulnerabilities.
HTML indentation in PHP
You need to create a logical structure while adding HTML code in a PHP file.
Use tabs and avoid using spaces.
Even when you mix PHP and HTML code (e.g. in a loop), you need to indent PHP blocks to match the HTML code.
The indentation level should match while closing HTML tags and PHP blocks.
blocks coding document elements meta standards
« Previous Next »