Home > Web Front-end > Front-end Q&A > Are css attributes case sensitive?

Are css attributes case sensitive?

藏色散人
Release: 2022-12-30 11:13:13
Original
5634 people have browsed it

CSS properties are not case-sensitive; because in CSS tag selectors and attribute selectors are case-insensitive, but class selectors and ID selectors may be case-sensitive, depending on the document language.

Are css attributes case sensitive?

The operating environment of this article: windows7 system, HTML5&&CSS3 version, Dell G3 computer.

Q: Is CSS case-sensitive? (Is CSS case sensitive?)

This question is not that easy to answer.

Some books say that CSS is not case-sensitive, but this statement is actually not that strict. Because ID selectors and class selectors are case-sensitive, and selectors are the backbone of CSS.

For example, the following code

<p class="box"></p>
<p id="case"></p>

<style>
  /*有效*/
  p {
    width: 100px;
    height: 100px;
    border: 1px solid;
  }

  /*无效*/
  .Box {
    background: red;
  }
  
  /*无效*/
  #Case {
    background: blue;
  }
</style>
Copy after login

Recommended: "css video tutorial"

Are css attributes case sensitive?

This is the code above Effect.

In the selector:

  • ID and class selectors are case-sensitive
  • Tag selectors and attribute selectors are not case-sensitive

Class selectors and ID selectors may be case-sensitive. This depends on the language of the document. HTML and XHTML define class and ID values ​​as case-sensitive, so the case of class and ID values ​​must match the corresponding values ​​in the document.

—— W3C

recommends using lowercase letters.

The above is the detailed content of Are css attributes case sensitive?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template