[Front-end Lao Zhao's CSS Concise Tutorial] 1-3 How to introduce CSS styles into HTML

 

Hello everyone, and welcome to this session. I'm Lao Zhao at the front end! In the previous class, we learned the basic syntax of CSS and how to use selectors. In this lesson we will focus on how to introduce CSS styles in HTML.

CSS is a language used to control the style of web pages, which allows us to easily modify the appearance and layout of web pages. In HTML, we can control the style of web pages by introducing CSS style sheets. So, how to introduce CSS style in HTML? Please listen to me slowly explain to you.

In HTML, we can introduce CSS styles in three ways: internal style sheets, external style sheets, and inline styles.

The first is the internal style sheet . Internal style sheets are CSS style codes written directly in HTML files. We can define an internal style sheet by adding a <style> tag inside the <head> tag. In the <style> tag, we can write arbitrary CSS code. The following is an example of an internal style sheet:

<head><style> h1{ color: red; } </style></head>

In this example, we define an internal stylesheet that sets the color of all h1 tags to red.

Next is the external style sheet . External style sheets are style codes written in separate CSS files that can be shared by multiple HTML files. We can use the <link> tag in the <head> tag to import an external style sheet. The following is an example of an external style sheet:

<h

Guess you like

Origin blog.csdn.net/superheaaya/article/details/129492504