简体   繁体   English

VS 代码中的链接 CSS 和 html 有问题。 外部 CSS 文件有问题

[英]Problem with link CSS and html in VS code. Problem with external CSS file

I am working in VS code and I am beginner.我在 VS 代码中工作,我是初学者。 I know how to write css in html style but css doesn´t work in external file.我知道如何以 html 样式编写 css,但 css 在外部文件中不起作用。

My code:我的代码:

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>WHY</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="style" href="style.css">
<style>
</style>
<body>
    <h1>rozkaz</h1>
    <p>smiech</p>
    <b>haha</b>
    <em>hehe</em>
    <mark style="background-color: blue;">hihi</mark>
    <p>Das ist  <del>ein</del>  kein Hund.</p>
    <p>Das ist  <del>ein</del>  <ins>kein</ins>  Hund.</p>
    <sup>hoho</sup>
</body>
</html>

CSS: CSS:

h1 {
    color: bisque;
}

I tried lot of tutorials but it didn´t work.我尝试了很多教程,但没有用。

You have an error in the link tag.您的链接标记有误。 The rel attribute should be "stylesheet" instead of "style". rel 属性应该是“stylesheet”而不是“style”。

<link rel="stylesheet" href="style.css">
<head>
  <link rel="stylesheet" href="style.css">
</head>

rel="style" should be replaced with rel="stylesheet" . rel="style"应替换为rel="stylesheet" also, it is better to include stylesheets inside a <head> tag另外,最好在<head>标签中包含样式表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM