search
HomeWeb Front-endHTML TutorialHTML introductory tutorial_html/css_WEB-ITnose

目标

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

什么是HTML

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

HTML是什么样的

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

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

点击查看效果


 


    第一个Html文档
 
 
    欢迎访问脚本之家!
 

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

和。

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

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

HTML文档可以包含的内容

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

文本 HTML对文本的支持是最丰富的,你可以设置不同级别的标题,分段和换行,可以指定文本的语义和外观,可以说明文本是引用自其它的地方,等等等等。 链接 链接用来指出内容与另一个页面或当前页面某个地方有关。 图片 图片用于使页面更加美观,或提供更多的信息。 列表 列表用于说明一系列条目是彼此相关的。 表格 表格是按行与列将数据组织在一起的形式。也有不少人使用表格进行页面布局。 表单 表单通常由文本输入框,按钮,多选框,单选框,下拉列表等组成,使HTML页面更有交互性。 框架 框架使页面里能包含其它的页面。

HTML文档格式详细说明

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

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

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

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

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

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

点击查看效果


 
分类目录...

 
当前分类内容列表...

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

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

常用标签介绍

文本

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

点击查看效果

6
4
红色的5
黑体的字

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

点击查看效果

Bold
italic
underline

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

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

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

,

,

,

,

,
,它们分别表示一级标题,二级标题,三级标题...

点击查看效果

HTML 30分钟教程


什么是HTML


...

HTML是什么样的


...

图片


标签用于在页面上添加横线。可以通过指定width和color属性来控制横线的长度和颜色。

点击查看效果


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

点击查看效果

图片简介

链接

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

点击查看效果

Unibetter大学生论坛
验证HTML

分段与换行

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

点击查看效果

这是第一段。


这是第二段。

也有人不用

,而用

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

点击查看效果

这是第一段。

这是第二段。

这是第三段。

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

标签专门用于标明不同的部分:

点击查看效果

页头内容

主体内容

页脚内容

Table

HTML documents are usually displayed from left to right and top to bottom in the browser, and they will automatically wrap when they reach the right side of the window. In order to achieve the column effect, many people use tables (

) for page layout (although the original intention of providing tables in HTML is not for layout).

tags usually contain several tags, represents a row in the table. The tag will contain Tag also Can be included by or or in
tags, with each representing a cell.

Click to view the effect



>




2008 Beijing


. They represent the table header, table body, and table foot respectively. When printing a web page, if the table is too large to be printed on one page, and will appear on every page.
. The difference is that
is very similar to and is also used in
means that this cell is the title of the row or column where it is located.

Click to view the effect

/th>



;/tr>
  ;

2004 Athens
Beijing


List

Table is used to represent two One-dimensional data (rows, columns), one-dimensional data is represented by a list. Lists can be divided into unordered lists (
    ), ordered lists (
    ) and definition lists (
    ). The first two types of lists are more common, and both use
  1. tags to contain list items.

    An unordered list represents a series of similar items, with no order between them.

    Click to view the effect

    • Apple
    • Orange
    • Tao


  2. The order among the items in the ordered list is very important, and the browser usually automatically generates numbers for them.

    Click to see the effect

    1. Open the refrigerator door
    2. Drive the elephant in
    3. > ;
    4. Close the refrigerator door


    Framework

    Finally let’s talk about frames, a once very popular technology, frames use Multiple documents can be displayed simultaneously in one window. There is no tag in the main frame page, it is replaced by .

    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 inside the tag.

    Click to see the effect



    frameset>

    What to do after 30 minutes

    This article only gives people who have never been exposed to HTML a preliminary impression of HTML, so many things are not discussed. This article does not list all tags in HTML, nor does it introduce all the attributes of the listed tags. In addition, things not mentioned include CSS, JavaScript, XHTML, XML, Web Standards, which I think are very important, and their relationship with HTML. However, it is unlikely that you can learn these in 30 minutes. Fortunately, as long as you get started, you can use many online resources to continue learning. Of course, it would be better if there is a paper book. In this regard, I recommend "The Definitive Guide to HTML and XHTML". Here are some online resources that I find good:

    HTML Language Reference (English)

    HTML Tutorial

  3. Reference to some terms I think you may already know
  4. Text document file, usually refers to a file whose content is data (not a program)
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
The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

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 Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool