CSS font styles and shorthand | Computer Programming | Khan Academy

– [Voiceover] Let’s see
what else we can change about the font. What if we want this first
paragraph to be bold? We could wrap the whole
paragraph in a strong tag, but that would be kind of
an abuse of the strong tag. We’re not really trying to say that the whole first
paragraph is a highlight, we just think it might look better bolded. So instead, we should use a
CSS property, font weight. Let’s go up to the relevancy assess rule and say font dash weight colon bold. Ta da, it’s bold! Now, what if we want to make all these lyrics italicized, slanted? Once again, we could
wrap them all in an m tag because the browser always defaults to giving m italicized style. But we shouldn’t do that, because that’s kind of
an abuse of the m tag. We’re not trying to
emphasize the whole song, we just think it might
look better italicized. So instead, we should use
a CSS property, font style. Let’s go up to our relevant
rules, song lyrics, say font dash style colon italic. Okay, great. Notice that we have a bunch
of font related properties in one rule for our lyrics. We’ve got font family,
font size and font style. If we want, we can actually bundle them up into a single property,
font italic, 13 px fantasy. Okay, and we can delete
the three properties that we used to have, and
everything looks the same. This is called a shorthand property since, as you can see, it’s a lot shorter. But me, I don’t like it,
because I always forget what order to write the properties in, and it’s just easier if I
write them out one at a time. So I’m going to bring
back what I had before. It’s up to you. If you’re a shorthander or a longhander. The important thing is to stay stylish.

Tags:, ,

Add a Comment

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