<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>CSS基本语法</title> <link href="demo.css" rel="stylesheet"> <style type="text/css"> /* p{color:red} */ </style> </head> <body> <!-- css:cascading style sheets(层叠样式表) * 语法:选择器{声明;声明2} * 选择器 标签选择器:p|h2 类选择器:(可以有多个相同的) 定义:.类名{} 调用:class="类名" ID选择器:(只能有一个) 定义:#ID名{} 调用:id="ID名"
优先级:id>类>标签 * 颜色值 * red|green|blue * #ff0000 = #f00 = red 取值范围:0-ff * rgb(255,0,0) 取值范围:0-255 * css嵌入方式 * 行内 style属性 eg:style="color:blue" * 内部 style标签 eg: <style type="text/css"> p{color:red} </style> * 外部 定义:xxx.css文件 使用:<link href="demo.css" rel="stylesheet"> * 优先级:就近原则 行内>内部>外部 --> <p>师傅领进门,修行在个人</p> </body> </html>