How to link html to css

王林
Release: 2023-05-05 14:30:47
Original
10619 people have browsed it

In web design, style sheets are a very important part, which can make our web pages more beautiful and easier to read. HTML can link to external style sheets, and the most commonly used style sheet is CSS. In this article, we will introduce how HTML links to CSS.

1. What is CSS?

CSS (Cascading Style Sheets) is a markup language used to describe the appearance style of documents such as HTML or XML. CSS can separate the appearance and format of a web page from its content by controlling fonts, colors, backgrounds, layout, etc.

2. Link CSS in HTML

To use CSS in HTML, we need to add theelement in thetag. This element is used to link to external CSS files. In theelement, we can specify the location, file name, and media type of the CSS file. Here is an example:

  
Copy after login

In this example, we name the CSS file "styles.css" through theelement, which is located in the directory of our current web page. This CSS file contains the styles we want to apply to the page.

When the browser parses HTML, it automatically downloads the CSS file and applies the styles in it to the HTML.

3. Internal CSS style sheet

In addition to linking external CSS files, we can also add the

Copy after login

In this example, two styles are defined within the