首页 > 代码库 > HTML&CSS学习笔记
HTML&CSS学习笔记
<table>
<thead>
<tr> // table row
<th></th> // table head
</tr>
</thead>
<tbody>
<tr>
<td></td> // table data
</tr>
</tbody>
</table>
<span></span>
- A
type
attribute that should always be equal to"text/css"
- A
rel
attribute that should always be equal to"stylesheet"
- A
href
attribute that should point to the web address of your CSS file
<link type="text/css" rel="stylesheet" href=http://www.mamicode.com/"stylesheet.css"/>
Many HTML elements support theborder
property. This can be especially useful with tables.
There‘s also a very special selector you can use to apply CSS styling to every element on the page: the *
selector.
class .
id #
Classes are useful when you have a bunch of elements that should all receive the same styling. Rather than applying the same rules to several selectors, you can simply apply the same class to all those HTML elements, then define the styling for that class in the CSS tab.
div > p { /* Some CSS */ }
This only grabs<p>
s that are nesteddirectly inside of<div>
s; it won‘t grab any paragraphs that are, say, nested inside lists that are in turn nested inside<div>
s.
This allows you to take elements of different types and give them the same styling.
IDs, on the other hand, are great for when you have exactly one element that should receive a certain kind of styling.
This allows you to apply style to a single instance of a selector, rather than allinstances.
pseudo-class selectors for links
a:hover {
color: #cc0000;
font-weight: bold;
text-decoration: none;
}
a:link{}
a:visited{}
p:first-child { color: red;}/*It‘s used to apply styling toonly the elements that are the first children of their parents.*/
p:nth-child(2) { color: red;}/*第二个孩子颜色为红色*/
body :first-child{
font-size: 50px;
}
body :nth-child(4){
font-size: 26px;
color:blue;
}
Make sure to leave a space betweenbody :nth-child
. If you don‘t have a space it means "find the body
tag that is an nth-child". If you have a space it means "find the nth-child of the body
tag".
HTML&CSS学习笔记
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。