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
Justin Molina
1,462 PointsWhen 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
1 Answer
Joachim Larsen
12,140 PointsI 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. :-)
Justin Molina
1,462 PointsMakes sense to me! Thanks for your response :)
rospa
2,945 Pointsrospa
2,945 PointsFont shorthand property requires a bare minimum of the
font-sizeandfont-familybeing declared, so if you're going to set more than those two (font-weight,font-style,line-heightetc) 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
bodytag to set it across the whole document, and then use the cascade to be more specific about other elements, such as heading sizes.