• About Me
  • Best Of
  • Contact Me
  • Forum

Jay Gaulard

  • Home & Living
    • Automotive & Mechanical
    • Carpentry & Building
    • Entertainment
    • Firewood & Heating
    • Gardening
    • Home Improvement
    • Lawn Care & Landscaping
    • Pets & Animals
  • Fitness & Recreation
    • Brazilian Jiu-Jitsu (BJJ)
    • Bushcraft & Camping
    • Hiking & Walking
  • Nature & Outdoors
    • Trees & Shrubs
    • Weather & Seasons
  • Technology & Internet
  • Travel & Destinations
  • Writing & Blogging
    • Ramblings & Opinion
You are here: Home / Technology & Internet / How To Remove Whitespace From HTML Code

How To Remove Whitespace From HTML Code

November 27, 2009

Yes folks, there is an easier way.

It’s common knowledge that whitespace in HTML code creates unnecessarily larger file sizes, increases bandwidth usage and slows down page load time. The only real reason to add whitespace to your code is for organization, but I have rarely found that helpful. Many HTML editors take the liberty of adding massive amounts of whitespace to your code for you. I guess they aren’t thinking about the real world.

Okay, just in case you don’t know what I mean, I’ll give you an example.

Below is a sample HTML table I just set up using Dreamweaver:

HTML table code - before

Do you see those unnecessary spaces before the TR and TD tags? Yup, that’s whitespace. Each one of those little spaces makes your web page larger.

So, how do you get rid of all that whitespace without going through all your code and making use of your delete key? It’s easy. I recently found a website called “Design215 Whitespace Remover” that does exactly that…and fast.

All you do is copy and paste your HTML code in the top white box and click on the “Compress” button. The tool removes all the whitespace in the code and shows the result in the bottom box. Copy and paste that code and you’re all set.

Here is what it did to the above code when I compressed it:

HTML table code - after


Pretty sweet.

Related posts:

  1. Duplicate Content – Mysite.com/ vs. Mysite.com/index.html
  2. Changing the Logo – MediaWiki – Version 1.10.0
  3. Avoiding Duplicate Content On Your Own Website
  4. How to Set Up a Custom 404 File Not Found Page
  5. How To Check Your Web Page HTTP Headers & Response Codes

Filed Under: Technology & Internet

What’s Next? Email Updates!

If you enjoyed reading this post as much as I enjoyed writing it, why not sign up to receive my posts by email? It's free and you can unsubscribe at any time!

Comments

  1. Scott Dial says

    October 9, 2014 at 11:03 am

    FYI, the removal of whitespace is not a worthwhile endeavor. Any decent web server is configured to use “gzip” encoding for the serving of html documents. The whitespace is readily compressed and will be not significantly change the amount of data involved in serving the document. While the end result will be smaller, it will not be a nearly as large of a gain as casual observation would suggest.

    Reply
  2. Jay Gaulard says

    October 9, 2014 at 11:04 am

    You are correct. For those who are on shared servers without the benefit of GZIP or MOD_DEFLATE, they have the option of removing some whitespace in their HTML. For others, getting rid of whitespace certainly helps clean up the code so it’s easier to read.

    Reply
  3. Chris says

    October 9, 2014 at 11:04 am

    Hi – we built a free to use custom command for people who use Dreameaver to clean up whitespace with just one click of a menu item.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CONNECT WITH ME

  • Email
  • Facebook
  • Google+
  • RSS
  • Twitter

RECEIVE MY POSTS BY EMAIL!

Interested in receiving my posts by email? This is your chance! Simply place your email address in the box below and I'll deliver each and every post I write directly to your inbox.

MOST POPULAR POSTS

  • Putting Wooden Sides On A Utility Trailer I am sure you are all just thrilled about my new utilit...
  • How to Fix a Symmons Shower Valve That Leaks What I'm about to share is for the greater good. I've d...
  • Building Wooden Sides For a Utility Trailer NOTE: Please read comments down below. This isn't a goo...
  • Assembling a John Deere 7-Bushel Rear Bagger I must say, this John Deere ride-on mower has been a re...
  • What Is a BMW Standard Scope? A few posts ago, I mentioned that I had to bring my car...
  • How Do I Get Rid of the Smell in My Brand New Wool Blanket? Question: All I can say is that this thing stinks. I ca...
  • Installing A Water Spigot In The Garage Valentine's day was here. I wanted to wash the car and...
  • Replacing a Stem Cartridge Spindle For Symmons Temptrol Shower Valve Wouldn't you just know it. As I was writing yesterday's...
  • Installing Lally Columns and Footings for Girder Beam One of the first things I noticed while looking at this...
  • Installing New Wooden Trailer Sides I know I've been down this road before, but I thought I...

Recent Comments

  • Jay Gaulard on Installing a Through-the-Wall Wood Stove
  • James on Installing a Through-the-Wall Wood Stove
  • Greg on Filling In a Basement Crawl Space
  • Swoopadoop on Using a Belt Sander to Sand Walls
  • Dani Lamirand on How to Effectively Move Warm Wood Stove Air From One Room to Another

Copyright © 2021 · Jay Gaulard My Personal Blog Blog · About · Best Of · Contact · Privacy / Terms · Sitemap