search
HomeWeb Front-endHTML Tutorial初学HTML 常见的标签(一) 文本标签_html/css_WEB-ITnose

  最近做iOS开发的过程中, 发现要涉及到JS和原生OC(Swift)的交互, 作为一个Developer, 本着克服一切问题的原则, 开始学习HTML, 在这里记录下自己的学习笔记, 方便以后的复习, 和新手初学的参考.

  HTML不同于过去学过的各种面向对象语言, 函数式语言, 它不像其他语言有明确的上下文的逻辑关系. 所以并不像其他语言一样需要有什么特定的基础, 希望这句话能让你远离学习过别的语言的阴影.

  HTML和CSS以及JavaScript的关系

  1. HTML是网页内容的载体.内容就是网页制作者放在页面上想要让用户浏览的信息, 可以包含文字, 图片, 视频等.

  2. CSS样式是表现. 就像网页的外衣. 比如,标题字体, 颜色变化, 或为标题加入背景图片, 边框等. 所有这些用来改变内容外观的东西称之为表现.

  3. JavaScript是用来实现网页上的特效效果, 如: 鼠标滑过弹出下拉菜单. 或鼠标滑过表格的背景颜色改变. 还有焦点新闻(新闻图片)的轮换. 可以这么理解, 有动画的, 有交互的一般都是用JavaScript来实现的.

  1, 语义化

  接触过HTML, 或者初学HTML, 我想接触的第一个专业词汇不是标签就是语义化了, 语义化的意义通俗点说就是明白每个标签的用途(不同的标签, 在什么情况下用, 怎么用, 这些就是语义化需要考虑的事情), 比如网页上的文章的标题, 想要在网页上体现的图表, 栏目名称, 段落等等, 都是标签能够实现的, 通过基本的标签加上CSS, 就可以写出一些很优美的页面.

  语义化的好处:

  1, 更容易被搜索引擎收录.

  2, 更容易让屏幕阅读器读出网页内容.

  2, 从最简单的程序解释下HTML

  作为一个程序员, 大家都应该知道"hello, world", 不管是学C, java, OC等等我想大家写出的第一个都应该是打印函数, 不过HTML是没有函数的, HTML主要是一种文本的显示, 类似于一个文本编辑器, 通过加上恰当的标签, 让文本排布成我们想要的样子, 所以下面是不会出现打印函数的(以后的JavaScript会有).

 1 <!DOCTYPE HTML> 2 <html> 3     <head> 4         <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5         <title>我的第一个网页</title> 6     </head> 7     <body> 8         <h1 id="Hello-World">Hello World</h1> 9     </body>10 </html>

  上面的就是HTML的Hello World.

  简单的介绍一下这段代码

  首先, 我们从代码中可以发现, 大部分的标签都是成对出现的, 所以分为开始标签和结束标签, 结束标签比开始标签会多出一个" / ", 比如上文中的和.

  然后, 我们可以看到, 代码中的标签是可以互相嵌套的, 但是不可以交叉, 中就嵌套了成对的很多标签, 但是却没有任何标签彼此交叉. 例如

这样就可以, 而这样就是不合法的.

  称为根标签, 所有的网页标签都在中.

  

标签用于定义文档的头部, 文档的头部描述了文档的各种属性和信息,包括文档的标题等。绝大多数文档头部包含的数据都不会真正作为内容显示给读者, 他是所有头部元素的容器. 头部标签有标题标签, JavaScript内嵌标签<script>, css样式标签<style>, 文件关联标签<link>, <meta>等. 以后会对标签进行逐一的介绍. <p>  <title></script> 标签, 在标签之间的文字内容是网页的标题信息, 它会出现在浏览器的标题栏中. 网页的title标签用于告诉读者和搜索引擎这个网页的主要内容是什么, 搜索引擎可以通过网页标签, 迅速的判断出网页的主体. 每个网页的内容都是不同的, 每个网页都应该有一个独一无二的title.

  

标签, 顾名思义, body也就是身体, 主体, 也就是说网页上面显示在界面上面的内容, 他也是内容标签的容器, 常见的内容标签有分级标题标签

~

, 段落标签

, , 图片标签初学HTML 常见的标签(一) 文本标签_html/css_WEB-ITnose等. 这些标签中的内容会在网页上面直接的体现出来.

  

标题标签, 网页中有很多的标题, 比如这篇博客的2, 从最简单的程序解释下HTML就是一个标题, 而标题也有着不同的大小尺寸, HTML中定义了标题的标签分别为

, 他们会默认加粗, 然后逐级减小字体.

 

  3, 其他的标签

  

段落标签, 在文章中, 我们需要条理清晰的一个一个段落, 这个时候我们就需要段落标签了, 默认样式中

前后都会有空白, 但是并不是我们正常使用中的首行缩进, 它通常不会让我们满意, 所以我们需要用css样式(
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
What are self-closing tags? Give an example.What are self-closing tags? Give an example.Apr 27, 2025 am 12:04 AM

Self-closingtagsinHTMLandXMLaretagsthatclosethemselveswithoutneedingaseparateclosingtag,simplifyingmarkupstructureandenhancingcodingefficiency.1)TheyareessentialinXMLforelementswithoutcontent,ensuringwell-formeddocuments.2)InHTML5,usageisflexiblebutr

Beyond HTML: Essential Technologies for Web DevelopmentBeyond HTML: Essential Technologies for Web DevelopmentApr 26, 2025 am 12:04 AM

To build a website with powerful functions and good user experience, HTML alone is not enough. The following technology is also required: JavaScript gives web page dynamic and interactiveness, and real-time changes are achieved by operating DOM. CSS is responsible for the style and layout of the web page to improve aesthetics and user experience. Modern frameworks and libraries such as React, Vue.js and Angular improve development efficiency and code organization structure.

What are boolean attributes in HTML? Give some examples.What are boolean attributes in HTML? Give some examples.Apr 25, 2025 am 12:01 AM

Boolean attributes are special attributes in HTML that are activated without a value. 1. The Boolean attribute controls the behavior of the element by whether it exists or not, such as disabled disable the input box. 2.Their working principle is to change element behavior according to the existence of attributes when the browser parses. 3. The basic usage is to directly add attributes, and the advanced usage can be dynamically controlled through JavaScript. 4. Common mistakes are mistakenly thinking that values ​​need to be set, and the correct writing method should be concise. 5. The best practice is to keep the code concise and use Boolean properties reasonably to optimize web page performance and user experience.

How can you validate your HTML code?How can you validate your HTML code?Apr 24, 2025 am 12:04 AM

HTML code can be cleaner with online validators, integrated tools and automated processes. 1) Use W3CMarkupValidationService to verify HTML code online. 2) Install and configure HTMLHint extension in VisualStudioCode for real-time verification. 3) Use HTMLTidy to automatically verify and clean HTML files in the construction process.

HTML vs. CSS and JavaScript: Comparing Web TechnologiesHTML vs. CSS and JavaScript: Comparing Web TechnologiesApr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

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.

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

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.