Dashes or underscores for CSS?

Which would be the most standards compliant long-term route? I hear people say it is preference, while other people say it can cause issues if you use a certain one.

Which of the below should I consider doing for all my CSS?

A. hyphens:

B. underscore

Thank you for any information you can provide regarding this!

hyphens are already in use for css properties: font-family, margin-left etcetera.

underscores can get in trouble with scripting languages like js. and css properties in js are based on camel Case: background-color(css) = backgroundColor(js).

you could just not use any of the two and use camelCase. or PascalCase.

Consider the one you’re most comfortable with. It doesn’t make much of a difference.

I prefer using a hyphen.

It also depends upon the markup language you use. Albeit I suspect they meant the id token (value) must begin with a letter ([A-Za-z]). So if you had id=“_a” or id=“1” it would be erroneous HTML and hence that is reflected in the CSS choices.

It doesn’t matter whether you use dashes or underscores, both are equally valid.

I would always try to avoid using camelCase or any technique that relies on capital letters, because case sensitivity is so easy to get wrong!