Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

When would it be ideal to use the font shorthand property?

Is the font shorthand property preferred or ideal to use over declaring all of those values individually? When would it be best to use it? Thanks

Font shorthand property requires a bare minimum of the font-size and font-family being declared, so if you're going to set more than those two (font-weight, font-style, line-height etc) to a single element then it's probably faster (and less code) to just use the shorthand.

I almost always use a font shorthand on a top-level element such as the body tag to set it across the whole document, and then use the cascade to be more specific about other elements, such as heading sizes.

1 Answer

I don't think that one way is more ideal than the other. You could choose the shorthand property if it makes sense when it comes to readability. Or not. There's nothing wrong with using the separate properties like font-family and font-size either.

I think it comes down to taste, and how long lines you want in your code. :-)

Makes sense to me! Thanks for your response :)