Home  >  Article  >  Web Front-end  >  What to do if css external style does not work

What to do if css external style does not work

藏色散人
藏色散人Original
2020-12-21 09:47:542020browse

The solution to the problem that css external style does not work: first open the css file with sublime editor; then modify the local css file encoding format to "utf-16LE"; finally resave and run.

What to do if css external style does not work

The operating environment of this tutorial: Windows 7 system, Sublime Text3&&css3 version. This method is suitable for all brands of computers.

Recommended: "css video tutorial"

As a front-end novice, I have been tinkering with the front-end for a few days. . Today I suddenly discovered that something I believed in had a problem. . For example, I wrote a css style document under the css directory: style.css. At this time, there is only one sentence in it:

body {
background-color: #ddd;
}

Then introduce this external css into my html file:

XML

Refresh the browser. . Wow, kao. It didn't respond, it didn't work. . I checked this path several times to make sure there was no problem, and opened chrome's F12 debugger. After making sure that the browser loaded the css file, I opened the file and found:

was garbled. . There should be something wrong with the encoding or the format, but I can't figure it out. . After consulting a front-end partner, I checked the current encoding of the web page:

shows UTF-16LE encoding. .

I tried it later and used the sublime editor to modify the local css file encoding format to this utf-16LE:

Rewritten the css code. Save and run. . Sure enough, that's it. .

But my html is specified as utf-8, and the css is utf-16, which makes me very unhappy. . So I asked again for a solution. It can be solved, and it's simple. .

Change the css to utf-8 and edit the code inside. Just declare the encoding format when introducing this css in html:

That is, add an attribute to the link tag: charset="utf-8". . . It's really that simple. . .

The above is the detailed content of What to do if css external style does not work. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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