HTML+CSS Easy to get started with cascading

What if there can be multiple css styles for the same element in the html file and these multiple css styles have the same weight value? Well, the cascading in this section helps you solve this problem.

Cascading means that there can be multiple css styles for the same element in the html file. When there are styles with the same weight, it will be determined based on the order of these css styles. The css style at the end is Will be applied

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>层叠</title>
	<style type="text/css">
		h1{
			color:green;
		}
		h1{
			color:red;
		}
	</style>
</head>
<body>
	<h1>php 中文网</h1>
</body>
</html>

The last text in h1 will be set to red. This cascading is easy to understand. It is understood that the later style will overwrite the previous style

So the priority of the previous css style is It’s not difficult to understand:

Inline style sheet (inside the tag) > Embedded style sheet (in the current file) > External style sheet (in the external file).


Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>层叠</title> <style type="text/css"> h1{ color:green; } h1{ color:red; } </style> </head> <body> <h1>php 中文网</h1> </body> </html>
submitReset Code