Electric Type

Multimedia

About Us

News

Help

Lean and Mean HTML

Page 3 — Kill the Invisibles

Did you know that every single carriage return and every single space used to indent your HTML makes your overall file size larger? Yup, it's true. The conclusion? Avoid all nonessential spaces and carriage returns.

Well, okay, that's taking it too far. Your HTML would be just a wee bit annoying to edit if your entire document were one long line of text. It does help to use indents to easily see and edit your table structures, but at least try to minimize what you use. If your code used to look like this:

    <TABLE BORDER=0>

        <TR>
            <TD> </TD>
            <TD> </TD>
            <TD>

            <TABLE BORDER=0>
                <TR>
                    <TD> </TD>
                    <TD> </TD>
                </TR>
                </TABLE>

            </TD>
        </TR>

        <TR>
            <TD> </TD>
            <TD> </TD>
            <TD> </TD>
        </TR>

        <TR>
            <TD> </TD>
            <TD> </TD>
            <TD> </TD>
        </TR>

    </TABLE>
Try this instead:
    <TABLE BORDER=0>
      <TR>
        <TD> </TD>
        <TD> </TD>
        <TD>
        <TABLE BORDER=0>
          <TR>
            <TD> </TD>
            <TD> </TD>
          </TR>
          </TABLE>
        </TD>
      </TR>
      <TR>
        <TD> </TD>
        <TD> </TD>
        <TD> </TD>
      </TR>
      <TR>
        <TD> </TD>
        <TD> </TD>
        <TD> </TD>
      </TR>
    </TABLE>
It's still very clear and easy to edit, but with only half the number of indents.

An even better solution is to not use any indents at all, but instead use line spaces to make basic table structures clear. You can also keep some tags on the same lines:

    <TABLE BORDER=0><TR>
    <TD> </TD>
    <TD> </TD>
    <TD>

    <TABLE BORDER=0><TR>
    <TD> </TD>
    <TD> </TD>
    </TR></TABLE>

    </TD></TR>
    <TR><TD> </TD>
    <TD> </TD>
    <TD> </TD></TR>
    <TR><TD> </TD>
    <TD> </TD>
    <TD> </TD></TR></TABLE>
This option makes for the smallest file size. It all comes down to a matter of personal habit and preference. If you aren't able to edit your code easily with this last option, then stick with the second option. All of this might seem picky, but every byte counts!

next page»


Dynamic HTML  

Frames  

HTML Basics  

Stylesheets  

Tables  

XML  

Javascript  

Database Connections  

Intro To Perl  

HTML 4.0  

User Blogs

Screen Shots

Latest Updates

Contact Us

Valid HTML 4.01!
Valid CSS!

Breadcrumb

© ElectricType
Maintained by My-Hosts.com
Site map | Copyright | Disclaimer
Privacy policy | Acceptable Use Policy
Legal information.