一、HTML基础语法
1、HTML是用树形结构来描述内容的,只要是树形结构就一定存在两种关系:父子关系(parent-child)和兄弟关系(siblings)。
<div>
<h1>Hello world</h1>
<p>i love study!</p>
</div>
div元素就是父节点,它有两个子节点h1和p。而h1和p之间互为兄弟关系。
2、现代HTML5标准模板
<!DOCTYPE html>
<html>
<head></head>
<body></body>
</html>
2.1、html元素是根节点,包含head元素和body元素。
2.2、head元素描述了有关站点的元信息。常见的元信息有4类:title,link,script和meta。
2.2.1、title是文档的标题,显示在浏览器标签页上。
2.2.2、link指定了页面要用到的相关CSS文件。
2.2.3、script用来引用相关的JavaScript文件。
2.2.4、meta作用比较多样化,首先它可以用来指定字符集编码,一般是utf-8,例如:<meta charset="utf-8">
,其次,它可以用来说明关键字,作者和描述,这对搜索引擎优化(SEO)起作用,例如:<meta name="description" content="This is what my website is all about!">
。
3、body元素包含了用户能够看到的网页的实际内容。
<!DOCTYPE html>
<html>
<head>
<title>第一个程序</title>
<meta charset="utf-8">
<style type="text/css"> h1 {
color:blue}</style>
<style>p {
color:white};</style>
<style>
a{
color:yellow;
background:black;
}
</style>
<style>h2 {
margin-left:60%}</style>
<style>
p {
text-indent:32px;
font-size:16px;
line-height:32px
}
</style>
<style>img{
position:absolute;left