1 定义字体不必每次都在<p></p>内写可以用css
<head><style type="text/css">body {background-color: red}p {margin-left: 20px}</style>
</head>统一样式
或者
<p style="color: red; margin-left: 20px"
>This is a paragraph</p>
或者外链
<head><link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
2当鼠标指针悬停于某元素之上时执行脚本
onmouseover
3css
下面的示意图为您展示了上面这段代码的结构:
提示:请使用花括号来包围声明。
4 定义了常态,通过继承可以定义特殊化的样式
strong {
color: red;
}
h2 {
color: red;
}
h2 strong
{
color: blue;
}
下面是它施加影响的 HTML:
<p>The strongly emphasized word in this paragraph is<strong>red</strong>.</p> <h2>This subhead is also red.</h2><h2>
The strongly emphasized word in this subhead is<strong>
blue</strong>
.</h2>
5定义新的选择器newID,使用为:
#newID
{color:red;}
<p id="newID"
>这个段落是红色。</p>
6定义新的类选择器newClass,使用为
类选择器以一个点号显示:
.center
{text-align: center}
<h1 class="center"
>This heading will be center-aligned</h1><p
class="center"
>This paragraph will also be center-aligned.</p>
7属性样式
下面的例子为带有 title 属性的所有元素设置样式:
[title]
{
color:red;
}
input[type="text"]{ width:150px; display:block; margin-bottom:10px; background-color:yellow; font-family: Verdana, Arial;}input[type="button"]{ width:120px; margin-left:35px; display:block; font-family: Verdana, Arial;}