HTML (non-XHTML), MIME type is text/html, allowing some tags to be omitted. With HTML 4 DTD, you can omit the following tags (those so-called avoidable elements are marked with strikethroughs)
</area> </base> <body> </body> </br> </col> </colgroup> </dd> </dt> <head> </head> </hr> <html> </html> </img> </input> </li> </link> </meta> </option> </p> </param> <tbody> </tbody> </td> </tfoot> </th> </thead> </tr>For example, your code is
<li>List item</li>Can be written as
<li>List itemFor example, the paragraph should
</p>At the end, you can just write
<p>My paragraphYou can even remove html, head, body (make sure this will make you comfortable before taking this as your coding specification).
HTML is still valid after omitting tags, while reducing file size. For general pages, you can save 5-20%.
HTML 5The developing HTML 5 provides some ways to reduce file size.
For example, page document type declaration
<!DOCTYPE html>contrast
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>Obviously HTML 5 has a shorter DTD.
HTML 5 is easy to use and shorter when specifying encoding for a page:
<meta charset=utf-8>replace
<meta http-equiv=content-type content=text/html; charset=utf-8>Normally, the browser handles HTML correctly.
In addition, in today's HTML 5, you can remove the type attribute that declares MIME type, such as
type=text/css or type=text/javascriptYou can use
<script> Alternative <script type=text/javascript> use <style> Alternative <style type=text/css>In all types of pages (even XHTHML) you can omit
type=text/cssHTML 5 makes this all easier.
Using all the above methods simultaneously will save 10%-20% (or even more) of the file, depending on your encoding style and the amount of text content in the page. The code will be cleaner and visitors will get website content faster. We use a lot of this technology in the Privacy Center project, saving 20% of the original file size.