Home > Web Front-end > HTML Tutorial > How to open css in html

How to open css in html

下次还敢
Release: 2024-04-22 09:33:12
Original
438 people have browsed it

Use the <link> element in HTML to link the CSS file to the document. The syntax is as follows: rel="stylesheet" is specified as a style sheet Type href="style.css" specifies the CSS file path

How to open css in html

How to use HTML to open CSS

HTML (super Text Markup Language) and CSS (Cascading Style Sheets) are two different languages ​​used in web development. HTML is used to define the structure and content of a web page, while CSS is used to control the style and layout of a web page.

To open CSS using HTML, you need to link the CSS file to the HTML document using the <link> element. <link> The syntax of the element is as follows:

<code class="html"><link rel="stylesheet" href="style.css"></code>
Copy after login

Among them:

  • rel="stylesheet" Specifies the type of element as style surface.
  • href="style.css" Specifies the path to the CSS file to link to.

For example, the following code will include the styles in a CSS file named "style.css":

<code class="html"><html>
<head>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <h1>这是一个标题</h1>
  <p>这是一个段落。</p>
</body>
</html></code>
Copy after login

Save the HTML document as "index.html" and then Open it in your browser. You will see that the styles in the "style.css" file are applied to the web page.

The above is the detailed content of How to open css in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template