这是我参与「第五届青训营 」伴学笔记创作活动的第 1 天
简述
HTML 是网页使用的语言,定义了网页的结构和内容。浏览器访问网站,其实就是从服务器下载 HTML 代码,然后渲染出网页。 网页的 HTML 代码由许许多多不同的标签(tag)构成。学习 HTML 语言,就是学习各种标签的用法。
-
HTML的基本单位是元素(element)
-
元素包括tag, content
-
ex.
-
-
元素可以嵌套
- ex.
<p>My cat is <strong>very</strong> grumpy.</p>
- ex.
-
元素包含属性(attribute)
-
空元素 : 不包含 content
- ex. img 元素
<img src = '来源' alt = '名称'>
- ex. img 元素
-
HTML 文档 : 元素的集合体
-
ex
-
<!DOCTYPE html>
— 文档类型 -
<html></html> — <html>
元素。该元素包含整个页面的内容,也称作根元素。 -
<head></head> — <head>
元素。该元素的内容对用户不可见.其中包含例如面向搜索引擎的搜索关键字(keywords)、页面描述、CSS 样式表和字符编码声明等。
-
<meta charset="utf-8">
— 该元素指定文档使用 UTF-8 字符编码 -
<title></title> — <title>
元素。该元素设置页面的标题 -
<body></body> — <body>
元素。该元素包含期望让用户在访问页面时看到的内容
-
-
-
常用HTML元素
-
img
- ex. img 元素
<img src = '来源' alt = '名称'>
- ex. img 元素
-
Heding
- ex.
<h1>主标题</h1><h2>顶层标题</h2><h3>子标题</h3><h4>次子标题</h4>
- ex.
-
Paragraph
- ex.
<p>这是一个段落</p>
- ex.
-
List
-
ex.
<ul> <li> test </li> <\ul>
无序列表用 ul , 有序用 ol
-
-
Link
- ex .
<a href = "link"> content <\a>
- ex .
-
Forms
这个部分课上没有具体说明, 个人看w3school整理的一些用法
-
The
<form>
Element-
ex.
-
action 属性定义了在提交表单时,应该把所收集的数据送给谁(URL)去处理。
-
method 属性定义了发送数据的 HTTP 方法(通常是 get 或 post)。
-
-
The
<input>
Element-
<input type="text">
- Displays a single-line text input field
-
<input type="radio">
- Displays a radio button (for selecting one of many choices)
-
<input type="checkbox">
- Displays a checkbox (for selecting zero or more of many choices)
-
<input type="submit">
- defines a button for submitting the form data to a form-handler.
-
<input type="button">
- Displays a clickable button
-
-
The Name Attribute for
<input>
-
each input field must have a name attribute to be submitted.
随表单一同提交到服务器的相关数据的名字
-
-
<label>
-
<lable for="xx">对应 <input .. id="xx">
好处, 点击label 跳转到对应 input
-
-
<textarea>
- 不受限制的大段
-
<button>
-
ex.
-
相比于用input, 好处是允许完整的HTML内容, input 只允许纯文本做标签
-