Solve the problem that HTML external reference CSS files do not take effect

Source: Internet
Author: User

Solve the problem that HTML external reference CSS files do not take effect

As a front-end hacker, I have been busy with the front-end for a few days .. Today I suddenly found something I believe in, and something went wrong .. For example, I wrote a css style document under the css Directory: style.css. There is only one sentence:

Body {background-color: # ddd ;}
Then introduce the external css in my html file:
 Refresh in the browser .. Wow, kao. It didn't respond, and it didn't work .. I checked this path several times and confirmed it was okay. Open chrome's F12 debugger. Make sure that the browser loads the css file. Then I open the file and see: 

Garbled characters .. It should be because the encoding format is wrong, but it cannot be used .. After consulting a front-end partner, I checked the current code of the webpage:

Displays the UTF-16LE encoding ..

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

Rewrite the css code. Save and run .. That's enough ..

But my html I specify UTF-8 while css is UTF-16, which makes me very uncomfortable .. So I asked about the solution. It can be solved, and it is very simple ..

Change css to UTF-8 and edit the code. You only need to declare the encoding format when html introduces this css:

Add charset = "UTF-8" to the link tag... It's actually that simple...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.