Home>Article>Web Front-end> What to do if external css is not displayed

What to do if external css is not displayed

藏色散人
藏色散人 Original
2021-02-08 10:45:35 3742browse

Solution to externally calling css not displaying: first open chrome's F12 debugger to view it; then use the sublime editor to modify the local css file encoding format to "utf-16LE"; and finally rewrite the css code. .

What to do if external css is not displayed

The operating environment of this article: windows7 system, Sublime Text3&&css3 version, DELL G3 computer.

Why is the externally called css not displayed (does not take effect)?

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

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

What to do if external css is not displayed

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:

What to do if external css is not displayed

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:

What to do if external css is not displayed

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:

What to do if external css is not displayed

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

Recommended: "css video tutorial"

The above is the detailed content of What to do if external css is not displayed. 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