前端-HTML(一)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a592381841/article/details/85028496

HTML

概念:超文本标记语言;是一种标记语言。

一、HTML标签

由一对尖括号包围的关键词,经常是成对出现;

开始标签(开放标签)

结束标签(闭合标签)

<html>
<body>

<h1>hello word</h1>
</body>
</html>

二、常用标签(一)

<html>
<body>
<p>这是段落</p>
<h1>这是标题1</h1>
<h2>这是标题2</h2>
<h3>这是标题3</h3>
<h4>这是标题4</h4>
<h5>这是标题5</h5>
<h6>这是标题6</h6>
<a href='http://www.baidu.com'>这是链接</a>
<p>img是图片</p>
<img src="www.jpg"  />
</body>

</html>

三、HTML元素

  1. HTML文档是由html元素组成的
  2. HTML元素是指从开始标签到结束标签的所有代码

3-1:HTML元素语法

元素以 开始标签起始,以结束标签终止;

元素内容为 开始标签与结束标签之间的内容

某些元素具有空内容,称之为空元素。并且空元素以开始标签进行关闭。(像<br/>)

大多数html都是拥有属性的。

html对大小写不敏感

四、html属性

html标签可以拥有属性。

属性通常以“键值对”的形式出现;例如:  name=“xiaoming”

扫描二维码关注公众号,回复: 4591921 查看本文章

属性总是在开始标签中被定义

<a href="http://www.baidu.ccom">

a的标签中有href属性,属性值为 http://www.baidu.com
</a>

五、Html注释

增加代码可读性,且浏览器会自动忽略注释

<!--这是注释,你们知道吗????-->

六、Html样式(style属性)

利用style属性 可以指定样式(CSS)

<html>
<body>
<h2 style="backgrond-color:green">
该标签的背景颜色是绿色
</h2>

</body>
</html>

七、文本格式化

<!DOCTYPE html>
<html>
<head>
	<title>文本格式化</title>
</head>
<body>
<b>粗体文字</b>
<big>大号文字</big>
<em>着重文字</em>
<i>斜体字</i>
<small>小体字</small>
<strong>加重文字</strong>
<p>你<sub>下标字</sub></p>
<p>你<sup>上标字</sup></p>
<del>删除文字</del>
<ins>下划线文字</ins>
<br/>
<code>

public void asd(){
	system.out.println("java");
}
</code>
<br/>

</body>
</html>

八、Html中的CSS

三种插入CSS的方式:

  1. 外部样式表
  2. 内部样式表
  3. 内联样式

三者优先级为  3>2>1

<!--外部样式表-->
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>

<!--内部样式表-->

<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>

九、HTML5的网站布局

语义元素:

header 定义文档或节的页眉
nav 定义导航链接的容器
section 定义文档中的节
article 定义独立的自包含文章
aside 定义内容之外的内容(比如侧栏)
footer 定义文档或节的页脚
details 定义额外的细节
summary 定义 details 元素的标题
<!DOCTYPE html>
<html>
<head>
	<title>网站布局</title>
</head>
<body>
<header>
<h1>定义页眉</h1>
</header>

<nav>
导航A<br>
导航B<br>
导航C<br>
</nav>

<section>
<h1>London</h1>
<p>
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
</p>
<p>
Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.
</p>
</section>

<footer>
Copyright W3School.com.cn
</footer>

</body>
</html>

猜你喜欢

转载自blog.csdn.net/a592381841/article/details/85028496
今日推荐