Started learning to program seriously early 2017. Love fixing problems so decided to switch careers from e-commerce and management to programming and web dev. Longterm goal is full stack developer.
What is the your recommendation for use of id's? I'm currently using them for single page elements that are not going to be reused i.e. a front page carousel or a contact form that won't be reused. Is there any reason you can't just use classes all the time?
No there's no reason you can't use classes everywhere for styling. Even if you think you'll only want to use a style once, there's no reason not to use a class for it. I can see why you would define "single-use" styles on the IDs but there isn't any advantage to doing that except for the higher specificity. I prefer to reserve IDs for other uses such as form labels and linking to anchor tags and keep all my styles defined by classes, for consistency.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What is the your recommendation for use of id's? I'm currently using them for single page elements that are not going to be reused i.e. a front page carousel or a contact form that won't be reused. Is there any reason you can't just use classes all the time?
No there's no reason you can't use classes everywhere for styling. Even if you think you'll only want to use a style once, there's no reason not to use a class for it. I can see why you would define "single-use" styles on the IDs but there isn't any advantage to doing that except for the higher specificity. I prefer to reserve IDs for other uses such as form labels and linking to anchor tags and keep all my styles defined by classes, for consistency.