搜索
首页web前端html教程什么是 HTML?

什么是 HTML?

Sep 04, 2024 pm 04:12 PM
htmlhtml5HTML TutorialHTML PropertiesHTML tags

超文本标记语言(HTML)是一种允许创建任何连接到互联网的人都可以查看的网站的语言。 根据一项调查,超过 55% 的受访者表示他们使用 HTML。

此外,学习 HTML 通常是任何 Web 开发人员旅程的第一步。 Web 开发人员的平均年收入为 61,718 美元,顶级开发人员的年收入突破了 103,000 美元大关。

超文本是一种通过单击称为超链接的文本进入下一页的上网方式。

什么是 HTML?

要点

  • 基本代码由 doctype 声明、HTML 标签、head 标签、title 标签和 body 标签组成。
  • 它可以在任何操作系统(例如 Windows、Mac 和 Linux)以及任何浏览器(例如 Google Chrome、Mozilla Firefox 和 Safari)上运行。
  • 它还有各种应用程序,例如创建个人博客、详细信息表、注册表、登陆页面、新闻通讯和在线作品集。
  • 优点是它是一个开放标准,易于学习,适合初学者,具有良好的社区支持,并且对搜索引擎友好。
  • 缺点包括安全性差、缺乏设计灵活性、在各种浏览器上输出不一致以及功能有限。

HTML 子集

1. XHTML(可扩展超文本标记语言)

  • XHTML 是一种基于 XML 的标记语言,这意味着它遵循严格的语法和语义规则。
  • XHTML 是 HTML 4 的继承者,旨在使该语言更加模块化和可扩展。
  • XHTML 文档必须格式正确且有效,这使得它们更难以创建,并且更加一致且可供更广泛的设备访问。

2. SGML(标准通用标记语言)

  • SGML 是一种用于定义标记语言的元语言,包括 HTML。
  • SGML 提供了描述文档结构和内容的标准语法,使其对于在不同系统之间交换信息非常有用。
  • SGML 是一个复杂而强大的系统,但其语法和复杂性使其不如 HTML 等简单标记语言得到广泛使用。

3. DHTML(动态 HTML)

  • DHTML 是指使用 HTML、CSS 和 JavaScript 创建动态、交互式网页。
  • DHTML 允许操作网页的内容、布局和行为以响应用户操作,而无需刷新页面。
  • DHTML 广泛用于创建动态效果,例如下拉菜单、工具提示和幻灯片放映。
  • 它还可以创建简单的动画和游戏。

4. TTML2(定时文本标记语言 2)

  • TTML2 是一种标记语言,用于以标准化方式表示定时文本内容,例如字幕和副标题。
  • TTML2 提供了一套全面的功能,用于设置定时文本的格式和样式,包括对多种语言和字体样式的支持。
  • TTML2 是确保聋哑和听力障碍用户可访问多媒体内容以及提高所有用户视频内容可用性的重要工具。

HTML 模板

每个 HTML 页面都有一个基本模板。它由以下部分组成:

文档类型声明:HTML 文档的第一行是 doctype 或文档类型声明,它定义了所使用的 HTML 版本。

语法:

<p><strong>Element</strong>:该元素是 HTML 文档的根元素,包含所有其他元素。</p>
<p><strong>语法:</strong></p>
<pre class="brush:php;toolbar:false">...

Head 元素:head 元素包含有关文档的信息,例如标题、元数据以及指向外部资源(例如样式表)的链接。

语法:

...

Title 元素:title 元素定义文档的标题,该标题显示在浏览器的标题栏中。

语法:

<title>Name of Web Page</title>

Body元素:body元素包含文档的主要内容,包括文本、图像和其他媒体。

语法:

...

除了这些基本标签之外,其他几个元素可以帮助添加内容以创建一个出色的网站。这些是-

标题:标题(H1、H2、H3 等)有助于构建内容并提供信息的层次结构。

语法:

<h1 id="Main-Heading">Main Heading</h1>

段落:段落 (

) 有助于定义文本块。

语法:

<p>Hello World</p>

链接:链接 () 允许用户导航到其他网页或其他资源。

语法:

<a href="https://www.EDUCBA.com">Link to EDUCBA website</a>

Images: Images (什么是 HTML?) can provide visual content in a document.

Syntax:

<img src="/static/imghwm/default1.png" data-src="image.jpg" class="lazy" alt="Image Description">

Code:



<title>EDUCBA’s Page</title>


<p> Hello World! This is EDUCBA’s first web page. </p>

Output:

什么是 HTML?

How to Create an HTML Table?

There are specific table tags to create a table – mainly,

, , and
,
.

Pre-requisites for HTML Table

For an absolute beginner, it is essential to know what the different table tags do before writing a basic code.

  • : Defines a table
  • : Defines a table row
  • : Defines a table header cell
  • : Defines a table data cell

    Student Details Table

    John has to create a webpage showing the names of students in a class along with their marks in mathematics and science. He draws the following table.

    Name Mathematics Science
    Mary 78 92
    Susan 98 84
    Amy 63 79

    Now, John wants to write the code to transform this table into an HTML table on a webpage. The steps-

    Step #1: Open an HTML code editor. This tutorial demonstrates how to write code in Visual Studio Code. If the PC doesn’t have VS Code, one can download it here.

    Step #2: Select File > New Text File.

    什么是 HTML?

    Step #3: Click on “Select a language” and then type HTML in the text box. Choose the HTML option to create a new HTML file.

    什么是 HTML?

    Step #4: Again, go to File > Save As and save the file with the filename.html format.

    什么是 HTML?

    什么是 HTML?

    Step #5: Add the basic code, i.e., HTML template of doctype declaration, HTML tag, head tag, title tag, and body tag, as shown below. Set the title as Student Details.

    Code:

    
    
    <title>Student Details</title>
    
    
    
    

    Output:

    什么是 HTML?

    Opening the file should show the following blank web page. Note the title in the browser tab has changed to “Student Details.”

    什么是 HTML?

    Step #6: Now, define the table using the

    tag inside the body tag. Define the first row using the tag, and add 3 headings cells – Name, Mathematics, and Science, using the tag, and adding the data in each cell using
    tag. Don’t forget to close the tags with a corresponding closing tag.

    Code:

    
    
    Name Mathematics Science

    Save the file and refresh the webpage to see the updated output:

    什么是 HTML?

    Step #7: Add the student details by defining a row for each student using

    tag. Close the table with the
    tag.

    Code:

    <tr>
    <td>Mary</td>
    <td>78</td>
    <td>92</td>
    </tr>
    <tr>
    <td>Susan</td>
    <td>98</td>
    <td>84</td>
    </tr>
    <tr>
    <td>Amy</td>
    <td>63</td>
    <td>79</td>
    </tr>

    Once again, save and refresh the webpage to see the final output:

    Code:

    
    
    <title>Student Details</title>
    
    
    
    <tr> <td>Mary</td> <td>78</td> <td>92</td> </tr> <tr> <td>Susan</td> <td>98</td> <td>84</td> </tr> <tr> <td>Amy</td> <td>63</td> <td>79</td> </tr>
    Name Mathematics Science

    Applications of HTML

    Application How Does HTML Help?
    Web pages To create web pages, provide the structure and content for displaying information in a web browser.

     

    E-commerce To create online stores, product catalogs, and shopping carts, allowing customers to purchase products and services online.

     

    Landing pages To develop compelling landing pages for websites that capture a visitor’s attention and encourage them to take a specific action.

     

    Newsletters It allows the creation of interactive and visually appealing newsletters, such as corporate newsletters, that deliver to subscribers via email.

     

    Online portfolios To create online portfolios for artists, photographers, and other creatives, showcasing their work and skills to potential clients and employers.

     

    Blogs One can create blogs, which are personal websites that provide a platform for writing and publishing articles and other content.
    Documentation It helps to create documentation and help files, providing information and guidance to users of the software and other products.

     

    Advertisements It can help make advertisements embedded on websites and social media platforms, promoting products and services to a wide audience.

     

    Forms To create a form, one can use
    elements.

     

    Advantages and Disadvantages

    Pros Cons
    Open Standard: It is free of cost and readily available. Limited Functionality: It cannot perform complex tasks like calculations or data storage.
    Easy to Learn: HTML tags are basic and in a readable format, enclosed in angle brackets. It’s easy to learn and use, even for non-programmers. Poor Security: It is vulnerable to security threats such as cross-site scripting (XSS) and SQL injection.
    Search Engine Friendly: Search engines can easily crawl and index the content of the pages. Inconsistent Browsers: Different browsers render HTML differently, leading to an inconsistent display of web pages on different browsers.
    Community Support: It has large community support and many online resources available for learning and troubleshooting. Poor Design Flexibility: It provides limited design options and creates static websites, making it difficult to create visually appealing dynamic websites without integrating CSS and JavaScript.

    Final Thoughts

    In conclusion, Hypertext Markup Language is a cornerstone of the World Wide Web. It provides a standardized way of defining the structure and content of a web page using a combination of tags and attributes. With HTML, one can create simple text-based web pages or complex, multimedia-rich applications. It is easy to learn and widely used, making it an essential skill for anyone interested in web development.

    FAQs

    Q1. How to convert an HTML to PDF?

    Answer: To convert, use a library or online service that supports HTML to PDF conversion.

    Q2. How to add an image in HTML?

    Answer: To add an image, use the 什么是 HTML? tag with the src attribute pointing to the image file’s URL or local path. Example:

    <img src="/static/imghwm/default1.png" data-src="image.jpg" class="lazy" alt="Alt text">

    Q3. Is HTML a programming language? What is the HTML used for?

    Answer: Hypertext Markup Language is not a programming language, it is a markup language used for creating web pages and other information displayed in a web browser. HTML defines the structure and content of a web page using a set of markup tags.

    Q4. How to add a video in HTML?

    Answer: To add a video, use the

    <video src="video.mp4"></video>

    One can also add controls to play, pause, and adjust volume with the controls attribute:

    <video src="video.mp4" controls></video>

    Q5. Is HTML case-sensitive?

    Answer: No, elements are not case-sensitive. However, as best practice, it’s good to follow the same casing in all tags or elements to improve code readability.

    Q6. How many tags are in HTML?

    Answer: There are over 140 tags specified in the HTML5 standard, but some of them have become obsolete and are not widely used. Commonly used tags include headings, paragraphs, links, images, lists, tables, forms, and multimedia elements like audio and video.

    Q7. What is HTML doctype?

    Answer: The first line of a document is the doctype or document type declaration, which defines the version of the HTML used. Example:

    <h4 id="Q-What-is-an-HTML-header"> Q8. What is an HTML header?</h4>
    <p><strong>Answer: </strong>The HTML <header> tag defines a header section in a document. This section typically contains information such as the page title, logo, and navigation menu. The header section is usually displayed at the top of the page, and its content is typically shared across multiple pages of a website. The header tag helps to define the structure and hierarchy of a web page and makes it easier to create a consistent look and feel across multiple pages.</header></p>

以上是什么是 HTML?的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
如何在标签上设置lang属性?为什么这很重要?如何在标签上设置lang属性?为什么这很重要?May 08, 2025 am 12:03 AM

设置标签的lang属性是优化网页可访问性和SEO的关键步骤。1)在标签中设置lang属性,如。2)在多语言内容中,为不同语言部分设置lang属性,如。3)使用符合ISO639-1标准的语言代码,如"en"、"fr"、"zh"等。正确设置lang属性可以提高网页的可访问性和搜索引擎排名。

HTML属性的目的是什么?HTML属性的目的是什么?May 07, 2025 am 12:01 AM

htmlattributeseresene forenhancingwebelements'functionalityandAppearance.TheyAdDinformationTodeFineBehavior,外观和互动,使网站互动,响应式,visalalyAppealing.AttributesLikutesLikeSlikEslikesrc,href,href,href,类,类型,类型,和dissabledtransfransformformformformformformformformformformformformformformforment

您如何在HTML中创建列表?您如何在HTML中创建列表?May 06, 2025 am 12:01 AM

toCreateAlistinHtml,useforforunordedlistsandfororderedlists:1)forunorderedlists,wrapitemsinanduseforeachItem,RenderingeringAsabulleTedList.2)fororderedlists,useandfornumberedlists,useandfornumberedlists,casundfornumberedlists,customeizableWithTheTtheTthetTheTeTeptTributeFordTributeForderForderForderFerentNumberingSnumberingStyls。

HTML行动:网站结构的示例HTML行动:网站结构的示例May 05, 2025 am 12:03 AM

HTML用于构建结构清晰的网站。1)使用标签如、、定义网站结构。2)示例展示了博客和电商网站的结构。3)避免常见错误如标签嵌套不正确。4)优化性能通过减少HTTP请求和使用语义化标签。

您如何将图像插入HTML页面?您如何将图像插入HTML页面?May 04, 2025 am 12:02 AM

toinsertanimageIntoanhtmlpage,usethetagwithsrcandaltattributes.1)usealttextforAcccessibilityandseo.2)instementRcsetForresponSiveImages.3)applylazyloadingWithLoadingWithLoading =“ lazy” tooptimizeperformance.4)tooptimizeperformance.4)

HTML的目的:启用Web浏览器可以显示内容HTML的目的:启用Web浏览器可以显示内容May 03, 2025 am 12:03 AM

HTML的核心目的在于让浏览器理解并展示网页内容。1.HTML通过标签定义网页结构和内容,如、到、等。2.HTML5增强了多媒体支持,引入了和标签。3.HTML提供了表单元素,支持用户交互。4.优化HTML代码可提升网页性能,如减少HTTP请求和压缩HTML。

为什么HTML标签对Web开发很重要?为什么HTML标签对Web开发很重要?May 02, 2025 am 12:03 AM

htmltagsareessentialforwebdevelopmentastheyandendenhancewebpages.1)heSdefinElayout,语义和互动性。2)SemantictagsiCtagSimproveCacsibilitieAndseo.3)pose poseriblesibilityAndseoandseo.3)poser

说明将一致的编码样式用于HTML标签和属性的重要性。说明将一致的编码样式用于HTML标签和属性的重要性。May 01, 2025 am 12:01 AM

一致的HTML编码风格很重要,因为它提高了代码的可读性、可维护性和效率。1)使用小写标签和属性,2)保持一致的缩进,3)选择并坚持使用单引号或双引号,4)避免在项目中混合使用不同风格,5)利用自动化工具如Prettier或ESLint来确保风格的一致性。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具

SecLists

SecLists

SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。