一、优先级
简单可以理解为就近原则;
<html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> .c1{ background-color: red; color: white; } .c2{ font-size: 26px; color: black; } </style> </head> <body> <div class="c1 c2" style="color: blue">abc</div> </body> </html>
二、存在形式
css样式可以存在于一个文件中;
在HTML中引入即可;
##HTML文件 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="commons.css" /> #引入 </head> <body> <div class="c1 c2" style="color: blue">abc</div> </body> </html> #css文件 .c1{ background-color: red; color: white; } .c2{ font-size: 26px; color: black; }
原文:https://www.cnblogs.com/weiyiming007/p/10809989.html