Home > Web Front-end > CSS Tutorial > What is CSS and what are its advantages

What is CSS and what are its advantages

清浅
Release: 2019-05-03 23:06:49
Original
11240 people have browsed it

Everyone is familiar with the use of CSS, so what is CSS and what are their advantages? You probably don’t know much about it yet. Today I will introduce the knowledge about CSS to you in detail, which has certain reference value. I hope to be helpful.

[Recommended course: CSS tutorial

The meaning of CSS

CSS (Cascading Style Sheets) is a computer language used to express document styles such as HTML. It is mainly responsible for handling the appearance style of the web page. Through it, you can change the width and height of the

box, text color, font style, paragraph spacing, background image or color used, according to different layout designs and screens of different devices. Size changes will produce different changes

Advantages of CSS

(1) Save time: You can write CSS once, and then introduce multiple CSS externally in multiple HTML pages Repeated use

(2) The page loads faster: By using CSS, you don’t need to write HTML tag attributes every time. You only need to write the CSS rule of a tag and apply it to the tag. All instances, so the code is greatly reduced which means shorter download times.

(3) Easy to maintain: If you want to make global changes, you only need to change the style, and all elements in all web pages will be updated automatically.

(4)Multi-device compatibility: Style sheets allow content to be optimized for many different types of devices.

How CSS works in browsers

The browser reads style definitions from top to bottom in the style sheet. This also means that the styles we define in the style sheet will override any previous styles previously defined in the style sheet, but we can redefine them in subsequent elements and they will not be overwritten

<style>
div{
width:100px;
height: 100px;
background-color: pink;
margin-top:5px;
}
</style>
<div></div>
<div  class="box"></div>
Copy after login

Image 6.jpg

After redefining the styles of the following elements

.box{
	background-color: yellow;
}
Copy after login

Image 7.jpg

Usage of CSS

By declaring a specific style for each element , CSS will be applied to HTML elements in the web page. Style declarations are often in the format:

Selector{
Set attribute value

}

div{
width:100px;
height: 100px;
background-color: pink;
}
Copy after login

Summary: The above is the entire content of this article , I hope that through this article, you can have a deeper understanding of CSS.

The above is the detailed content of What is CSS and what are its advantages. 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