New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Start learning with our library of video tutorials taught by experts. Get started

CSS: Visual Optimization
Illustration by

Removing unused selectors


From:

CSS: Visual Optimization

with Justin Seeley

Video: Removing unused selectors

Another great way to make sure that your CSS is as clean and as tidy and as fast as it needs to be is to remove something called unused selectors. And so, if you've developed a pretty long CSS document, it might actually be a little difficult to find an unused selector, and exactly what is an unused selector? Well, it's something like this right here on line 70, where I have this class called button and then after that there's really nothing to find. Either this means that I defined it somewhere else, I put it in a selector group, or it's just something that never really fully got developed and didn't make it into the final shipping version of the website.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
CSS: Visual Optimization
1h 11m Beginner Feb 12, 2013

Viewers: in countries Watching now:

Take a tour of a workflow that optimizes CSS code for easier navigation, organization, and readability. In this course, author Justin Seeley covers best practices for writing CSS in an easy-to-read format, commenting code, developing a table of contents, and adopting other methods that help produce "cleaner" code. The course also contains tips for speeding up development with some online tools and simplification techniques.

Topics include:
  • Exploring good versus bad style sheets
  • Creating section headings
  • Indenting code for enhanced readability
  • Creating single- and multi-line comments
  • Avoiding unnecessary tags and classes
  • Creating master color and typography guides
  • Simplifying comments
Subjects:
Web Web Graphics Web Development
Software:
CSS
Author:
Justin Seeley

Removing unused selectors

Another great way to make sure that your CSS is as clean and as tidy and as fast as it needs to be is to remove something called unused selectors. And so, if you've developed a pretty long CSS document, it might actually be a little difficult to find an unused selector, and exactly what is an unused selector? Well, it's something like this right here on line 70, where I have this class called button and then after that there's really nothing to find. Either this means that I defined it somewhere else, I put it in a selector group, or it's just something that never really fully got developed and didn't make it into the final shipping version of the website.

Same thing holds true down here for the content h2. Maybe I've fixed that somewhere else, the aside h3, same thing. And so there's going to be all of these different empty selectors throughout your documents that you need to find and get rid of. Why do you need to get rid of them? Because that's one less line of CSS that has to be parsed by the browser. And so what we are going to do is find all of these, and we can do that by using a Find/Replace. If your code editor does not support Find/Replace just take this and paste it into a Word processing program that does and then come back and re paste it afterwards. And so what we are going to be looking for, the find part is we are going to be looking for an open curly brace and a closed curly brace, so just open and close, right next to each other and then I'm going to find the first one, oh okay, there we go.

And so I can just select that and remove that line, and we'll go, we'll find another one. Oh, okay, there it is. It highlights it for me, and so we'll just back that up. And I'm also going to remove any unnecessary white space that might be around there, and so let's go back here, yep, there's one more, so we'll just select that and the unused line above it and remove it, and there we go. And so now that little noise means that I can't find anymore so that means all of my unused selectors have been eliminated. And so from here all I would do is save this. I have now eliminated three unused and unnecessary selectors.

I've also remove some more lines of white space. thus making this document load a little bit faster and making my code look that much cleaner.

There are currently no FAQs about CSS: Visual Optimization.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed CSS: Visual Optimization.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.