Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What are the commonly accepted naming conventions for CSS ID and class selectors?

0
Posted

What are the commonly accepted naming conventions for CSS ID and class selectors?

0

I’ve worked on projects that have used the lower-case, hyphenated style and on projects that use the camelCase style where the first letter is lowercase, but subsequent word breaks garner a capital letter. I think a lot of times this choice is influenced by the style conventions of whatever programming language you are using for the web framework. I think what’s more important is that you are consistent in style naming the CSS classes and IDs, even if that means adopting the existing project’s standard over your preferred style. This answer ignores what makes a class name good, because I think that is more related to how make good variable names and readable code. One important thing to remember, though, is that the CSS class names should describe what is being displayed, not how it’s being displayed. In other words, don’t name things “leftColumn” and “rightColumn”, but rather “main” and “secondary.” The CSS class name is sort of the bridge between the content in the document and the p

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123