How to link CSS in web pages

PHPz
Release: 2023-04-13 10:54:10
Original
2058 people have browsed it

In web design, CSS (style sheet) is one of the skills that must be mastered. Linking CSS files is a common operation in web design. Let us learn how to link CSS.

First, we need to prepare a CSS file. CSS files usually have a .css suffix and contain CSS style rules. You can use a text editor or CSS editor to write CSS files. Here is a simple CSS file example:

body {
    background-color: lightblue;
}

h1 {
    color: navy;
    margin-left: 20px;
}
Copy after login

The above CSS style rules set the background color and title color of the web page. Next we need to link this CSS file with the HTML document so that the styles can be applied to the web content.

There are two ways to link CSS files: internal styles and external styles.

Internal style

Internal style refers to writing CSS style rules in the