top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why css selectors mixed up with cases (uppercase and lowercase) don't apply the styles?

+1 vote
556 views
Why css selectors mixed up with cases (uppercase and lowercase) don't apply the styles?
posted Jun 22, 2017 by Navya

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

CSS is case insensitive in all matters under its control; however, some things, such as the document markup language, are beyond its control. HTML is case insensitive in most respects, except when it comes to certain attribute values, like the id and class attributes. XHTML, being XML, is always case sensitive.

This means that the CSS element type selectors for an HTML document are case insensitive, though they’re case sensitive for XHTML, as this example shows:

h1 {
  font-size: 150%;
}
H1 {
  color: red;
}

The first rule will apply to all level-one headings in HTML (even if the tags are written as <H1>...</H1> in HTML) and XHTML.

The second rule will apply to all level-one headings in HTML, even if the tags are written as <h1>...</h1>. It won’t apply to any heading element in an XHTML document.

answer Jun 23, 2017 by Ananna Dey
...