用两天的时间将HTML学完,整理一下笔记。由于是在边学习时边记的笔记,只记录了自己不熟悉的。排版不是很规范,慢慢学习,一步一步来。
一.基础布局
1.文件类型说明
<!DOCTYPE html>
2.HTML文件以<html>开始,以</html>结束。/表示标签结束。
3.<head>,不显示在浏览器上,一般是属性的设置;
<body>,要显示的文章内容
4.段落:<p>
5.注释:<!---comments--->
6.换行符:<br>,无结束标签
<hr>,增加一条横线
<pre>:元素中的文本以固定宽度的字体(通常是Courier)显示,并且它保留了空格和换行符。
例:
<DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>this is a heading</h1>
</body>
</html>
二.链接
1.链接:<a>,链接的目的地在href属性指定
<a href="address">this is a link</a>
2.图片:img,源文件(src),替换文件(alt)(在无法显示时打开),宽度和高度
<img src="address" alt="imgname" width="100" height="142">
3.图片为链接:href为要链接到的地址,src为图片地址,alt为名称
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;border:0;">
</a>
三.属性attribute:
lang="",语言
title,鼠标指到有显示
Attribute
|
Description
|
alt
|
Specifies an alternative text for an image, when the image cannot be displayed
|
disabled
|
Specifies that an input element should be disabled
|
href
|
Specifies the URL (web address) for a link
|
id
|
Specifies a unique id for an element
|
src
|
Specifies the URL (web address) for an image
|
style
|
Specifies an inline CSS style for an element
|
title
|
Specifies extra information about an element (displayed as a tool tip)
|
四.style:对应标签的CSS属性设置
The following tags describe metadata: <title>, <style>, <meta>, <link>, <script>, and <base>style attribute:<tagname style="property:value;">(在对应属性的开头标签里,并不是在head)
background-color;color;记得还有个分号
font-family(字体);font-size(大小)
text-align(对齐)
- <b> - Bold text
- <strong> - Important text
- <i> - Italic text
- <em> - Emphasized text
- <mark> - Marked text
- <small> - Small text
- <del> - Deleted text
- <ins> - Inserted text
- <sub> - Subscript text
- <sup> - Superscript text
五.引用quotation
HTML Quotation and Citation Elements
Tag
|
Description
|
Defines an abbreviation or acronym( 缩写或首字母缩略
词)
<p>The <abbr title="World Health Organization">WHO</abbr> was founded in 1948.</p>
| |
Defines contact information for the author/owner of a document
| |
Defines the text direction(文本方向)
<bdo dir="rtl">This text will be written from right to left</bdo>
| |
Defines a section that is quoted from another source
<blockquote cite="http://www.worldwildlife.org/who/index.html">
| |
Defines the title of a work
| |
Defines a short inline quotation
|
六.class,id属性:
要定义样式的一种特殊类型的元素,添加类属性的元素, 然后定义为与特定类元素的样式
<p class="error">I am different</p>
在<head>
p.error {
color: red;
}
id属性(在internal CSS使用),即在<style>
<style>
#p01 {
color: blue;
}
</style>
<body>
<p id="p01">I am different.</p>
</body>
七.HTML表格
定义HTML表格:
<table>定义
每行<tr>
表头标题<th>
表中数据<td>
增加边框
p {
border: 1px solid powderblue;
边框厚度 实线 颜色
padding: 30px;
边框宽度
}
Tag
|
Description
|
Defines a table
| |
Defines a header cell in a table
| |
Defines a row in a table
| |
Defines a cell in a table
| |
Defines a table caption
| |
Specifies a group of one or more columns in a table for formatting
| |
Specifies column properties for each column within a <colgroup> element
| |
Groups the header content in a table
| |
Groups the body content in a table
| |
Groups the footer content in a table
|
八.列表list
1.无序:一个无序列表开始与<ul>标签。每个列表项开始与 <LI>标记
2.有序:有序列表开始与<OL>标记。每个列表项开始与<LI>标记
块级元素:<div>,占用可用的全宽(伸到左侧和右侧,只要它可以)
内联元素:<span>,不启用新行,只需要站尽可能多的宽度
九.HTML CSS
有三种方式:
1.inline:在元素旁标签开头用style设置属性
2.internal:在<head>部分,用<style>标签,每个要设置属性的部分用{ };
<head>
<style>
body {background-color: powderblue;}
h1 {color: blue;}
p {color: red;}
</style>
</head>
3.external:在head添加CSS链接
<head>
<link rel="stylesheet" href="styles.css">
</head>
????rel表示的是什么
外部样式表:
使用一个完整的URL链接到一个样式表:
<link rel="stylesheet" href="https://www.w3schools.com/html/styles.css">
链接到位于对当前网站的HTML文件夹的样式表
<link rel="stylesheet" href="/html/styles.css">
链接到位于同一文件夹中当前页面的样式表:
<link rel="stylesheet" href="styles.css">
链接:
<a href="url">link text</a>
<a href="https://www.w3schools.com/html/">Visit our HTML tutorial</a>
十.Iframes
Iframes
<iframe src="URL"></iframe>
例
<iframe src="demo_iframe.htm" style="border:none;"></iframe>
<iframe src="demo_iframe.htm" name="iframe_a"></iframe>
<p><a href="https://www.w3schools.com" target="iframe_a">W3Schools.com</a></p>