Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Normalizing icon fonts

From: Deploying Icon Fonts for the Web

Video: Normalizing icon fonts

You never really know where you're going to need to use an icon font. I'm going to set the letter spacing to normal.

Normalizing icon fonts

You never really know where you're going to need to use an icon font. Some icons might appear inside of a paragraph, others might appear inside of something like a heading or a list, and you might use it in a stand alone element like a div or some type of other black level element. Well that type of flexibility is really one of the strengths of icon fonts. But it also means that you have to be aware of the apparent element that it's inside of. You have to be aware of that apparent elements styling that could cause your icons to display incorrectly.

That's why it's a really good idea to do what we call normalizing our icon styling by going ahead and setting explicit values for things like font weight and font style. And so, to demonstrate that, I'm going to use the normalize HTM file, found in the 02_03 directory. I'm just going to scroll down, I'm previewing it in the browser right now. And I've got this particular icon used in three different places. One is inside of a heading, another is inside of a italicized paragraph, and another one is just sort of standing off all by itself inside of a div tag.

And as you can see, it's actually affecting it slightly differently in each instance. It's italicized over in the paragraph, it's a little bolder that the actual icon inside the heading because the heading is bold as well, and there's a weird spacing issue going on inside the div tag down there, that isn't really being controlled through margins. So there is a lot of styling going on to our icons that aren't driven by the icons, themselves, but rather the parent elements. So if I go back into my code editor, I've got the normalize file here open. And you can see kind of how this is constructed.

So we're assigning the icon through the use of the data icon attribute. We'll talk about how to do this a little bit later on, but I just wanted to point out the fact that this particular version of icon font that we're using, Chunky Mobile, is actually encoded to the private use area, so that's what you're seeing there. Here, we have it inside of the heading. Here, we have it inside of the heading, here we have it inside paragraph, and the, here we have it all by its little lonesome. So, three separate places. I'm going to switch over to the CSS file for normalize.htm and that would be base.css. You can find this in the _css directory in the same folder.

And I'm going to scroll all the way down towards the bottom, just saving myself a little bit of time by just shooting right down there. Okay. So I have a little area in here called icon font styles. And these are the only things that I really need to do right here to get my font to display. But I'm going to create some blank lines up here so that I can control the styling. Now there are a lot of different ways to normalize them, and a lot of how you write the selector that's going to do the normalization is based on how you're deploying it. For this example, I'm going to write a global selectory using the universal selector.

That's going to target anything that might have that data icon attribute. That's kind of a really big, broad selector, and it's not something that I might use every single time I depoy icon font, so I don't want you to watch this exercise and think oh, this is the way that I should do this from now on. It's about memorizing the properties that I want you to sort of take with you, not the selector that I'm writing here. So I'm going to do a star, and then I'm going to do attribute-selector, where I'm targeting any element that has the attribute of data-icon. Because that is, in this instance, how we're assigning the icon font.

Open up more curly braces, and then inside that now I'm going to go in and start normalizing it. So these are the properties that I want you to be aware of. So the first thing i'm going to do is font weight. And I'm going to assign this a font weight of 400 I could have said normal, but I really like being explicit with that value 400, because that is what my font was mapped to, in terms of being a regular font. So that's very explicitly saying that you want the default weight for that. Alright, so a font-weight of 400. I'm going to do a font-style of normal. I'm going to do text-transform of none.

I'm going to do font-variant of normal. I'm going to set the letter spacing to normal. And I'm going to set line height to one. Now let's talk about these individually. Okay, so, font weight and font style, those are kind of obvious. I want them to not appear bold. I don't want it to italicize my icons, so both of those things are going to override any parent styles that might be affecting it. Now, text transform and font variant, it's probably really doubtful that I'm going to have too many icons in parents that have small caps applied to it.

But I'm sort of covering my bases here. As far as text transform goes, capitalize or upper-case probably won't affect an icon font. But I don't want to take the chance. So, for different various browsers and devices out there, I'm just going to go ahead and say don't do it at all. Letter spacing, this could really affect my icons if I am trying to control the positioning beside other pieces of text. So I'm going to go ahead and set that to normal. And for my line height, a lot of times you can use line height to control the vertical alignment or vertical placement of an icon within a parent. So I'm just going to go ahead and set that to one as the default, and then I would override that anywhere that I would need to.

What I'm going to do is save this, then go back out to my browser. Okay, so here I am in the browser, and this is the original one. So you can see everything's still italicized. We've got the standalone one that's awkwardly positioned down there. And then we have to bold one here. And if I click over to our normalized version of this, you can see a couple of changes occur right away. Obviously, this icon is not italicized anymore, this one has moved up because of the line height isn't tied to whatever it was inside of before. And, although this is a little bit more subtle, if I toggle back and forth, you can see that the bold versus normal is actually causing that to display maybe a little but crisper, maybe not as fat in certain areas.

It's a really subtle difference but there's a definite difference there in image quality. So keep in mind that even though we used that sort of global selector, that you can normalize your icon fonts either that way through the use of a global selector or you can do like individual selectors as you assign the icon font elements. It's really up to you. You're just going to want to use the most efficient styling possible, but in large part how you normalize your icon fonts is going to be driven by how you choose to deploy them.

Show transcript

This video is part of

Image for Deploying Icon Fonts for the Web
Deploying Icon Fonts for the Web

21 video lessons · 1952 viewers

James Williamson
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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.


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 Already a member? Log in

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 Deploying Icon Fonts for the Web.

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 preferences from 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

Your file was successfully uploaded.

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.