Analysis and solution of the reasons why HTML external reference CSS files are not effective

Analysis and solution of the reasons why HTML external reference CSS files are not effective
As a front-end novice, I tinkered with the front-end for a few days. . Today I suddenly discovered that something I firmly believed in actually had problems. . For example, I wrote a CSS style document under the CSS directory: style.css. There was only one sentence in it:
XML/HTML CodeCopy content to clipboard
  1. body {
  2. background-color: #ddd;
  3. }
Then I import this external css into my HTML file:
XML/HTML CodeCopy content to clipboard
  1. < link   rel = "stylesheet"   type = "text/css"   href = "css/style.css" >    

Refresh in the browser. . Wow, kao. There was no response. It didn't work. . I checked the path several times to make sure there was no problem, and opened Chrome's F12 debugger. After making sure the browser loaded the CSS file, I opened it and saw:


It's garbled. . There should be something wrong with the encoding format, but I don't know what to do. . After consulting a front-end partner, I checked the current encoding of the web page:


The displayed encoding is UTF-16LE. .
Later I tried it and used the sublime editor to modify the local css file encoding format to this utf-16LE:


Rewrote the css code. Save the run. . It works as expected. .
But my HTML is specified as UTF-8, while the CSS is UTF-16, which makes me very unhappy. . So I asked for a solution again. It can be solved, and it's simple. .
Change the css back to utf-8 and edit the code inside. Just declare the encoding format when importing this CSS in HTML:


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

This is all I have to say about the reasons why HTML external referenced CSS files do not take effect and the solutions. I hope it will be helpful to you!

<<:  Detailed explanation of MYSQL stored procedure comments

>>:  CSS3 to achieve menu hover effect

Recommend

Vue custom optional time calendar component

This article example shares the specific code of ...

Detailed explanation of fuser command usage in Linux

describe: fuser can show which program is current...

WeChat applet implements countdown for sending SMS verification code

This article shares the specific code for the WeC...

How to add automatic completion commands for docker and kubectl on Mac

Introduction to kubectl kubectl is a command line...

Implementation of vue-nuxt login authentication

Table of contents introduce Link start Continue t...

React new version life cycle hook function and usage detailed explanation

Compared with the old life cycle Three hooks are ...

Several ways to easily traverse object properties in JS

Table of contents 1. Self-enumerable properties 2...

Analyze the difference between computed and watch in Vue

Table of contents 1. Introduction to computed 1.1...

How to modify the time in centos virtual machine

The one above shows the system time, and the one ...

Related operations of adding and deleting indexes in mysql

Table of contents 1. The role of index 2. Creatin...

MySQL query specifies that the field is not a number and comma sql

Core SQL statements MySQL query statement that do...

A QQ chat room based on vue.js

Table of contents Introduction The following is a...

Detailed explanation of the use of shared memory in nginx

In the nginx process model, tasks such as traffic...