Relative Content

Tag Archive for htmlcsscss-selectors

Why some characters are not allowed as CSS selectors?

I had two <h2> headings in html. I wanted to style them separately using CSS. For that I tried to use numbers ‘1’ and ‘2’ as class names. But when I tried to select them using h2.1, h2.2 in CSS selectors, it did not work.

Why some charactors are not allowed as CSS selectors?

I had two h2 headings in html. I wanted to style them separately using CSS. for that I tried to use numbers ‘1’ and ‘2’ as class names. But when I tried to select them using h2.1 , h2.2 in CSS selectors it did not work. Then I googled and got to know there are some characters not allowed a CSS selectors. Now I know there are some rules for selectors. But I am wondering the reason why CSS has prohibited some characters as selectors ?!