The longer individual HTML codes are within an HTML document, the more confusing and convoluted the document appears, particularly if you don't have a great deal of coding experience. Overlong HTML codes are additionally problematic if the field you need to paste your code has a character limit. No matter your reason for wanting to do so, shorten and consolidate codes whenever possible.
Use relative pathnames whenever possible. For example, if you insert a link to a file hosted at yourwebsite.com/content/files/file1.jpg and are currently editing yourwebsite.com/content/pages/contact.html, use the relative path "files/file1.jpg" rather than the full Web address to shorten the code.
Consolidate features such as alignment and display size within a page element, rather than outside of it. Rather than centering an image like this, for example:
<img src="files/file1.jpg" align="center"></img>
Remove HTML tables and use paragraph or line break tags instead. For example, rather than placing two linked images on separate lines this way:
<td><a href="http://myurl.com/page1.html"><img src="http://myurl.com/image1.jpg"></img></a>
<td><a href="http://myurl.com/page2.html"><img src="http://myurl.com/image2.jpg"></img></a>
Control stylistic elements of your site that appear on all its pages using your Custom Style Sheet, or CSS, rather than manually applying formatting to text or images within HTML code. In some instances, shortening long HTML code is a matter of eliminating it entirely.