How to Make Longer HTML Codes Into Short Codes

Save

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:

    <center><img src="files/file1.jpg></img></center>

    Use:

    <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:

    <table>

    <tr>

      &lt;td>&lt;a href="http://myurl.com/page1.html">&lt;img src="http://myurl.com/image1.jpg">&lt;/img>&lt;/a>

    &lt;/td>

    &lt;td>&lt;a href="http://myurl.com/page2.html">&lt;img src="http://myurl.com/image2.jpg">&lt;/img>&lt;/a>

    </tr>

    </table>

    Do this:

    <p><a href="&lt;img">http://myurl.com/page1.html">&lt;img src="&lt;/img>&lt;/a>&lt;/p">http://myurl.com/image1.jpg">&lt;/img>&lt;/a>&lt;/p>

    <p><a href="&lt;img">http://myurl.com/page2.html">&lt;img src="&lt;/img>&lt;/a>&lt;/p">http://myurl.com/image2.jpg">&lt;/img>&lt;/a>&lt;/p>

  • 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.

References

Promoted By Zergnet

Comments

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!