search
HomeWeb Front-endHTML TutorialHTML 30-minute introductory tutorial
HTML 30-minute introductory tutorialJan 25, 2019 am 11:27 AM
HTML入门html tutorial

30分钟内让你明白HTML是什么,并对它有一些基本的了解。一旦入门后,你可以从网上找到更多更详细的资料来继续学习。

什么是HTML

【推荐教程:HTML教程

HTML是英文Hyper Text Mark-up Language(超文本标记语言)的缩写,它规定了自己的语法规则,用来表示比“文本”更丰富的意义,比如图片,表格,链接等。浏览器(IE,FireFox等)软件知道HTML语言的语法,可以用来查看HTML文档。目前互联网上的绝大部分网页都是使用HTML编写的。

HTML是什么样的

简单地来说,HTML的语法就是给文本加上表明文本含义的标签(Tag),让用户(人或程序)能对文本得到更好的理解。

下面是一个最简单的HTML文档:

<html>
  <head>
    <title>第一个Html文档</title>
  </head>
  <body>
    欢迎访问<a href="http://deerchao.net">deerchao的个人网页</a>!
  </body>
</html>

所有的HTML文档都应该有一个标签,标签可以包含两个部分:

和。

标签用于包含整个文档的一般信息,比如文档的标题(标签用于包含标题),对整个文档的描述,文档的关键字等等。文档的具体内容就要放在标签里了。

标签用于表示链接,在浏览器(如IE,Firefox等)中查看HTML文档时,点击标签括起来的内容时,通常会跳转到另一个页面。这个要跳转到的页面的地址由标签的href属性指定。上面的中,href属性的值就是http://deerchao.net。

HTML文档可以包含的内容

通过不同的标签,HTML文档可以包含不同的内容,比如文本,链接,图片,列表,表格,表单,框架等。

文本

HTML对文本的支持是最丰富的,你可以设置不同级别的标题,分段和换行,可以指定文本的语义和外观,可以说明文本是引用自其它的地方,等等等等。

链接

链接用来指出内容与另一个页面或当前页面某个地方有关。

图片

图片用于使页面更加美观,或提供更多的信息。

列表

列表用于说明一系列条目是彼此相关的。

表格

表格是按行与列将数据组织在一起的形式。也有不少人使用表格进行页面布局。

表单

表单通常由文本输入框,按钮,多选框,单选框,下拉列表等组成,使HTML页面更有交互性。

框架

框架使页面里能包含其它的页面。

HTML文档格式详细说明

前面介绍了HTML文档的基本格式,下面再做一个详细说明。

HTML文档可以用任何文本编辑器(比如记事本,UltraEdit等)创建,编辑,因为它的内容在本质也只是一些文本。

在HTML文本中,用尖括号括起来的部分称为标签。如果想在正文里使用尖括号(或者大与号小与号,总之是同一个东西),必须使用字符转义,也就是说转换字符的原有意义。

标签本质上是对它所包含的内容的说明,可能会有属性,来给出更多的信息。比如HTML 30-minute introductory tutorial(图片)标签有src属性(用于指明图片的地址),width和height属性(用于说明图片的宽度和高度)。HTML里能使用哪些标签,这些标签分别可以拥有哪些属性,这些都是有规定的,知道了这里说的基本知识之后,学习HTML其实也就是学习这些标签了。本文后面会对常用的HTML标签做出简短的介绍。

标签通常有开始部分和结束部分(也被称为开始标签和结束标签),它们一起限定了这个标签所包含的内容。属性只能在开始标签中指定,属性值可以用单引号或双引号括起来。结束标签都以/加上标签名来表示。有时候,有些标签并不包含其它内容(只包括自己的属性,甚至连属性都没有),这种情况下,可以写成类似这样:HTML 30-minute introductory tutorial。注意最后的一个空格和一个反斜杠,它说明这个标签已经结束,不需要单独的结束标签了。

某些标签包含的内容中还可以有新的标签,新的标签名甚至可能还可以与包含它的标签的名称相同(哪些标签可以包含标签,可以包含哪些标签也是有规定的)。比如:

<div>
<div>分类目录…</div>
<div>当前分类内容列表…</div>
</div>

在这种情况下,最后出现的标签应该最先结束。

HTML文档里所有的空白符(空格,Tab,换行,回车)会被浏览器忽略,唯一的例外是空格,对空格的处理方式是所有连续的空格被当成一个空格,不管有一个,还是两个,还是100个。之所以有这样的规则是因为忽略空白符能让使用HTML的作者以他觉得最方便的格式来排列内容,比如可以在每个标签开始后增加缩进,标签结束后减少缩进。由于英语文本中空格用得很普遍(用于分隔单词),所以对空格做了这样的特殊处理。如果要显示连续的空格(比如为了缩进),应该用 来代表空格。

常用标签介绍

文本

最常用的标签可能是了,它用于改变字体,字号,文字颜色。

<font size="6">6</font>
<font size="4">4</font>
<font color="red" size="5">红色的5</font>
<font face="黑体">黑体的字</font>

加粗,下划线,斜体字也是常用的文字效果,它们分别用,,表示:

<b>Bold</b>
<i>italic</i>
<u>underline</u>

还有一些标签,用来指出包含的文本有特殊的意义,比如(表示缩写),(表示强调),(表示更强地强调),(表示引用),

(表示地址)等等。这些标签不是为了定义显示效果而存在的,所以从浏览器里看它们可能没有任何效果,也可能不同的浏览器对这些标签的显示效果完全不同。

一篇很长的文章,如果有合适的小标题的话,就可以快速地对它的内容进行大致的了解。在HTML里,用来表示标题的标签有:

,

,

,

,

,
,它们分别表示一级标题,二级标题,三级标题...
<h1>HTML 30分钟教程</h1>
<h2 id="什么是HTML">什么是HTML</h2>
...
<h2 id="HTML是什么样的">HTML是什么样的</h2>
...

图片


标签用于在页面上添加横线。可以通过指定width和color属性来控制横线的长度和颜色。
<hr width="90%" color="red" />

HTML 30-minute introductory tutorial标签用于在页面上添加图片,src属性指定图片的地址,如果无法打开src指定的图片,浏览器通常会在页面上需要显示图片的地方显示alt属性定义的文本。

<img src="/static/imghwm/default1.png"  data-src="http://www.xx.com/Icons/valid-xhtml10"  class="lazy"   alt="图片简介" />

链接

超级链接用标签表示,href属性指定了链接到的地址。标签可以包含文本,也可以包含图片。

<a href="http://deerchao.net">deerchao的个人网站</a>
<a href="http://validator.w3.org"><img src="/static/imghwm/default1.png"  data-src="http://www.xx.com/Icons/valid-xhtml10"  class="lazy"   alt="验证HTML" /></a>

分段与换行

由于HTML文档会忽略空白符,所以要想保证正常的分段换行的话,必须指出哪些文字是属于同一段落的,这就用到了标签

<p>这是第一段。</p>
<p>这是第二段。</p>

也有人不用

,而用

只表示换行,不表示段落的开始或结束,所以通常没有结束标签。

这是第一段。<br>
这是第二段。<br />
这是第三段。

有时,要把文档看作不同的部分组合起来的,比如一个典型的页面可能包括三个部分:页头,主体,页脚。

标签专门用于标明不同的部分:
<div>页头内容</div>
<div>主体内容</div>
<div>页脚内容</div>

表格

HTML文档在浏览器里通常是从左到右,从上到下地显示的,到了窗口右边就自动换行。为了实现分栏的效果,很多人使用表格(

)进行页面排版(虽然HTML里提供表格的本意不是为了排版)。

标签里通常会包含几个标签,代表表格里的一行。标签又会包含标签还可以被
标签,每个 代表一个单元格。
<table>
<tr>
<td>2000</td><td>悉尼</td>
</tr>
<tr>
<td>2004</td><td>雅典</td>
</tr>
<tr>
<td>2008</td><td>北京</td>
</tr>
</table>

里的或或包含。它们分别代表表头,表正文,表脚。在打印网页的时候,如果表格很大,一页打印不完,和将在每一页出现。

里边,不同的是
非常相似,也用在
代表这个单元格是它所在的行或列的标题。
<table>
<thead>
<tr><th>时间</th><th>地点</th></tr>
</thead>
<tbody>
<tr><td>2000</td><td>悉尼</td></tr>
<tr><td>2004</td><td>雅典</td></tr>
<tr><td>2000</td><td>北京</td></tr>
</tbody>
</table>

列表

表格用于表示二维数据(行,列),一维数据则用列表表示。列表可以分为无序列表(

    ),有序列表(
    )和定义列表(
    )。前两种列表更常见一些,都用
  1. 标签包含列表项目。

    无序列表表示一系列类似的项目,它们之间没有先后顺序。

    <ul>
    <li>苹果</li>
    <li>桔子</li>
    <li>桃</li>
    </ul>

    有序列表中各个项目间的顺序是很重要的,浏览器通常会自动给它们产生编号。

    <ol>
    <li>打开冰箱门</li>
    <li>把大象赶进去</li>
    <li>关上冰箱门</li>
    </ol>

    框架

    最后谈一下框架,曾经非常流行的技术,框架使一个窗口里能同时显示多个文档。主框架页里面没有

    标签,取代它的是。

    The attributes Rows and Cols of the tag are used to specify how many rows (columns) there are in the frameset (frameset), and the height (width) of each row (column).

    The

    tag can contain the tag, and each tag represents a document (the src attribute specifies the address of the document).

    If you feel that such a page is not complicated enough, you can also include the

    tag in the tag.



The above is the detailed content of HTML 30-minute introductory tutorial. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Mar 04, 2025 pm 12:32 PM

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

How do I use HTML5 form validation attributes to validate user input?How do I use HTML5 form validation attributes to validate user input?Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

What are the best practices for cross-browser compatibility in HTML5?What are the best practices for cross-browser compatibility in HTML5?Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

How to efficiently add stroke effects to PNG images on web pages?How to efficiently add stroke effects to PNG images on web pages?Mar 04, 2025 pm 02:39 PM

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

What is the purpose of the <datalist> element?What is the purpose of the <datalist> element?Mar 21, 2025 pm 12:33 PM

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

How do I use the HTML5 <time> element to represent dates and times semantically?How do I use the HTML5 <time> element to represent dates and times semantically?Mar 12, 2025 pm 04:05 PM

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

What is the purpose of the <progress> element?What is the purpose of the <progress> element?Mar 21, 2025 pm 12:34 PM

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

What is the purpose of the <meter> element?What is the purpose of the <meter> element?Mar 21, 2025 pm 12:35 PM

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools