-
Notifications
You must be signed in to change notification settings - Fork 0
Description
In your CSS, ideally you should only use classes for styling.
This adds consistency, and makes you CSS more organised. It also makes your CSS more scalable. (if you style directly on the a element, but then later decide you want another link, with different styling, then you run into problems! If you style on classes, this problem doesn't come up).
@oliverjam raised a great issue on one of fac11's projects so I will quote him with some information.
This is an amazing resource: cssguidelin.es
Styling with IDs is generally not a great idea. They have the highest specificity of any selector, and can only ever be used once, which prevents you from reusing styles.
Styling bare HTML elements isn't necessarily a bad thing, but it means those styles will always be present on any other uses of that element. So if you want an input styled differently you would have to override the styles you have applied to the element. Generally best practice is to use classes as a styling hook, as they can be reused as much as you want, have low specificity and are generally easier to work with. (see the CSS Guidelines link above for more info)