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

CSS setting div background image implementation code

Adding background image control to a component re...

Comparison of the advantages of vue3 and vue2

Table of contents Advantage 1: Optimization of di...

Linux RabbitMQ cluster construction process diagram

1. Overall steps At the beginning, we introduced ...

How to create a responsive column chart using CSS Grid layout

I have been playing around with charts for a whil...

Detailed explanation of Django+Vue+Docker to build an interface testing platform

1. Two words at the beginning Hello everyone, my ...

Implementation of Docker cross-host network (overlay)

1. Docker cross-host communication Docker cross-h...

Design theory: the basics of font design

<br />Words are the inevitable product of hu...

Detailed analysis of compiling and installing vsFTP 3.0.3

Vulnerability Details VSFTP is a set of FTP serve...

Linux virtual memory settings tutorial and practice

What is Virtual Memory? First, I will directly qu...

Detailed explanation of anonymous slots and named slots in Vue

Table of contents 1. Anonymous slots 2. Named slo...

Three Discussions on Iframe Adaptive Height Code

When building a B/S system interface, you often en...

A brief discussion on using virtual lists to optimize tables in el-table

Table of contents Preface Solution Specific imple...

Three ways to copy MySQL tables (summary)

Copy table structure and its data The following s...