Can anyone comment on the best practice for where (in a CSS class) to place common CSS properties like font-family?
I see various ways to apply the font-family property to an element. Examples that I’m aware of:
-creating a class specifically for font-family or other font related styles
-inline styling in a specific element
-creating a class for all h2 headings or
I was reading a bit in Google’s html/css style guide but couldn’t find anything specific.
I would say it depends on what you want to achieve. If you’re using one font-family, I suppose it’s fine assigning it to something like
Inline styling is less recommended because it’s more of a pain in the neck to edit later - you have to sift through all your html file and…what if you miss an element?
Yeah that makes sense. I think I’m leaning towards creating specific classes to handle and define specifics for fonts (family, size, color, etc). Then I can assign the attribute to the elements I want.
You might want to take a look at this : 30 CSS selectors you should know, and having this cheatsheet could also be handy.
It’s nice to know how to select an element without finding yourself with a mess of IDs to deal with.
I think I’ve already referred to those links about 50 times on these forums, so my apologies if it’s a repeat for you !
Thanks! Great resources. I’ll dig in.