• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Good Books
  • Tools
  • Blog
  • Darren
  • Contact
  • Hire Me
Small Biz Geek

Small Biz Geek

Small Business Design, Marketing & Technology Journal

Solving small business design, marketing & tech problems

  • The Internet
  • Marketing
  • Graphic Design
  • Web Dev
  • Web Design
  • Social Media
  • Privacy & Security
  • Tech
  • Misc

Delete Blank Lines in CSS Stylesheet & Increase Website Speed

Published: May 5, 2015; Updated: June 12, 2017 Filed Under: Video, Web Development

In this post I’ll reveal a quick method to remove blank lines in your CSS stylesheet using Dreamweaver. This will help speed up the time it takes to load your site.

Dreamweaver Find & Replace Screenshot

The same fix can be used if you’ve experienced the unfortunate problem of having lots of unwelcome spaces mysteriously inserted in your source code.

Less lines in the source code results in an improved load time. You can use the free Notepad++ instead of Dreamweaver and you can learn more about that here.

 

The Problem: CSS Stylesheet Blank Lines

I’m a big fan of WordPress but even their stylesheets have some blank lines.

By default, a typical WP theme has a single line space after every closing brace.

I’ve highlighted these spaces in the screenshot below:

WordPress CSS Stylesheet Line Breaks

This isn’t anything to worry about. There are a gazillion websites with stylesheets just like it and it’s not a problem.

But it would be better to remove the spaces and achieve a slightly faster load.

It Gets Messy

While single blank lines between CSS rules isn’t problematic, lots and lots of spaces are.

Multiple blank lines tend to appear when numerous customisations are made to the CSS.

In the past I’ve made the mistake of not closing the gaps, potentially adding unwanted load time.

Here’s a screenshot:

CSS Rules Stylesheet Blank Lines

Look familiar?

This is a situation you might encounter if you’re asked to update a website another designer/developer has previously worked on.

I believe in leaving things in a better state than you found it which is another reason to run the fix shown at the end of the post.

It Gets Worse

Ok, one more anecdote before I tell you how to delete these pesky lines.

The other day I downloaded my stylesheet from my server with the intention of making a few changes.

I copied style.css to my desktop using FileZilla.

However, when I opened the stylesheet in Dreamweaver I was confronted by this horror:

Stylesheet Gaps on Every Other Godamn Line

Yep. An extra blank line had been inserted between every line. The stylesheet was now twice as long!

2582 lines of code had become 5164 lines of code!

 

The Fix: Remove Blank Lines from Stylesheet in Dreamweaver

I have two solutions.

Fix 1

In Dreamweaver go to Commands > Apply Source Formatting.

The blank lines should immediately close up. If this doesn’t work, try the following alternative method.

Fix 2

Here’s what you need to do:

  1. Open your stylesheet in any version of Dreamweaver.
  2. Press CTRL & F (Or select Find and Replace from the Edit menu).
  3. Enter [\r\n]{2} in the Find field.
  4. Enter \n in the Replace field.
  5. Check the box “Use regular expression”.
  6. Click Replace All.

Dreamweaver will then spend 1 – 2 minutes automatically removing the blank lines.

You’ll end up with a stylesheet which is shorter and faster loading.

Save it and copy back to your website directory.

Watch this video for a run through:

Watch video on YouTube

 

If the first solution does not work, try this instead:

  1. Enter \r\n\r\n in the Find field
  2. Enter \n in the Replace field.
  3. Click Replace All.

Analysis

For the amount of time it takes, you’d might as well employ the tactic of removing blank lines.

It’s especially important if you’ve been making lots of edits and have forgotten to close up those spaces. It makes it easier if you’re working with other web designers.

You Might Also Be Interested In...

  • Create a Twitter Automatic Voucher Code System
  • Stop GoDaddy Spamming Branded Footer Links to WordPress Installatron Sites 🪧
  • Twitter Tweet Chats: The Good, The Bad and The Spammy

Filed Under: Video, Web Development Tagged With: CSS, Dreamweaver, Site speed, Stylesheet, Websites

About Small Biz Geek

I'm Darren, helping small businesses with design, marketing & tech.

Small Business Website Design

Do you need help with something web related?

Hire Me

Reader Interactions

Subscribe to Blog Feed by Email

Your email address won't be shared. You'll never be spammed. Check your inbox to confirm opt-in.

Comments

  1. omid says

    August 6, 2016 at 6:59 am

    tanx

    Reply

Add Your Thoughts Cancel reply

Your email address is safe and will NOT be shared with anyone else.

Hateful, spammy or abusive comments will not be tolerated.

For more information please see the comment policy.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Search Website

Latest Blogs

  • Is Generative Engine Optimisation (GEO) the Answer to the Future of Search? 🎨
  • How Hiding Your Phone Number and Using a Booking System Repels Time Wasters and Frees Up Time 🗓️
  • “Fucking Good Content” – Dan Kelsall (Book Review) 📘
  • Scam Poetry: The Time I Was Recruited to the Cult of Amway ⚠️
  • A Story of Seductive Social Media Success and Neglected Email Strategy 🏚️
  • The Classic Social Media Trend Destined to Ruin Your Business 😭
  • Looking for Online Work? Don’t Fall for this Fake Hays Recruitment WhatsApp Scam ⚠️
  • Cream of the Crap: How Fake Reviews, Bad Businesses and Dangerous Products Rise to the Top 💣
  • Exposed: The Hong Kong Investment “Fraud Recovery” Scammer Deceiving Victims 🤑
  • Computer Says No: Does Your Website Work for People with Disabilities? ♿
  • Chinese Tinder Profiles Are Using Photos of Pretty Girls to Scam “Investors” 💋
  • Small Biz Owners “Trapped” Using Email Addresses Belonging to Internet Service Providers 🪤
  • In the Pandemic, QR Codes are Finally Proving Worthy in the West 😷
  • Small Businesses Finally Start Marketing… and All It Took Was a Global Pandemic 🏁

Footer

Primary Navigation

Home
About Darren
Good Books
My Tools
Blog Posts
Hire Me
Contact Me

Derby & Nottingham Area

The Internet
Marketing
Graphic Design
Website Development
Website Design
Social Media
Technology
Miscellaneous
Privacy & Security

Let’s Connect

Twitter
YouTube
LinkedIn
RSS

Small Business Blog · Privacy Policy · Commenting Policy · Website Disclaimer · ICO number: ZA305900


Written and designed by Ilkeston Web Design

  • Home
  • Good Books
  • Tools
  • Blog
  • Darren
  • Contact
  • Hire Me