HTML(HyperText Markup Language,超文本标记语言)是用于创建网页的标准标记语言。了解HTML是进行网络爬虫、网页开发等活动的基础。下面是一些基本但重要的HTML知识点:
元素和标签:
<tagname>Content goes here...tagname>
属性:
<tagname attribute="value">Content goes here...tagname>
文档结构:
: 定义文档类型。: HTML文档的根元素。: 包含元数据(如、、等)。: 包含页面的可见内容(如、、![]()
等)。DOCTYPE html>
<html>
<head>
<title>Page Titletitle>
head>
<body>
<h1>This is a headingh1>
<p>This is a paragraph.p>
body>
html>
标题和段落:
到: 定义标题,是最高级别的标题。: 定义段落。<h1>This is a headingh1>
<p>This is a paragraph.p>
链接和图片:
<a href="https://www.example.com">This is a linka>
<img src="image.jpg" alt="An image">
列表:
: 定义无序列表。
: 定义有序列表。: 定义列表项。<ul>
<li>Item 1li>
<li>Item 2li>
ul>
表格:
: 定义表格。: 定义表格行。: 定义表头单元格。: 定义表格单元格。 <table>
<tr>
<th>Header 1th>
<th>Header 2th>
tr>
<tr>
<td>Row 1 Col 1td>
<td>Row 1 Col 2td>
tr>
table>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
表单:
: 定义表单。: 定义输入字段。: 定义多行文本输入字段。: 定义按钮。
<form>
<input type="text" name="name">
<textarea name="comment">textarea>
<button type="submit">Submitbutton>
form>
- 1
- 2
- 3
- 4
- 5
-
CSS与JavaScript:
- CSS (Cascading Style Sheets): 用于样式化HTML元素。
- JavaScript: 用于为网页添加交互性。
<head>
<style>
body {font-family: Arial, sans-serif;}
style>
<script>
function myFunction() {
alert("Hello World!");
}
script>
head>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
Div和Span标签:
: 是一个块级元素,常用于组合块级元素,并通过CSS样式化。: 是一个内联元素,常用于组合文本,并通过CSS样式化。 <div style="background-color:lightblue">
<h3>This is a heading in a div elementh3>
<p>This is some text in a div element.p>
div>
<span style="color:blue">This text is in blue colorspan>
- 1
- 2
- 3
- 4
- 5
- 6
-
ID和Class属性:
id属性提供唯一标识,每个HTML文档中的id值都应该是唯一的。class属性用于定义元素的类名,可以将相同的样式应用于具有相同class值的多个元素。
<div id="uniqueElement">This element has a unique IDdiv>
<p class="styled-text">This text has a specific style.p>
<p class="styled-text">This text has the same style.p>
- 1
- 2
- 3
-
HTML5新标签:
, , , , 等是HTML5中引入的新标签,用于更具语义化的组织内容。
<header>
<h1>Site Titleh1>
<nav>
<ul>
<li><a href="#home">Homea>li>
<li><a href="#services">Servicesa>li>
ul>
nav>
header>
<section>
<article>
<h2>Article Titleh2>
<p>Article Contentp>
article>
section>
<footer>
<p>Copyright © 2023p>
footer>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
-
嵌入内容:
: 可以嵌入另一个HTML页面。和: HTML5新增的标签,用于嵌入视频和音频内容。
<iframe src="https://www.example.com" width="600" height="400">iframe>
<video controls>
<source src="movie.mp4" type="video/mp4">
Your browser does not support the video tag.
video>
<audio controls>
<source src="sound.mp3" type="audio/mp3">
Your browser does not support the audio tag.
audio>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
-
表单输入类型:
- HTML5引入了一些新的输入类型如
, , , 等,以支持更多的用户输入选项。
<input type="date" name="birthdate">
<input type="email" name="email" placeholder="Enter your email">
- 1
- 2
-
数据属性 (data-*):
- 自定义数据属性,以存储页面或应用程序的私有自定义数据,以
data-为前缀。
<div data-role="page" data-theme="a">This div has some data attributesdiv>
- 1
-
响应式设计相关标签和属性:
- 如
,用于控制页面在不同设备上的呈现。
这些是HTML中较为高级或HTML5中新引入的特性,了解这些有助于编写更现代、更高效的HTML代码,并能更好地理解和分析网络上的网页结构。
-
相关阅读:
[C#基础训练]FoodRobot食品管理部分代码-1
云服务器安装 redis
家庭理财管理系统设计与实现
【机器学习-周志华】学习笔记-第十五章
Gartner:机器人流程自动化RPA三大误区
数据库第四章习题-数据库安全性控制
Oracle故障案例之-19C时区补丁DSTV38更新
【浅学Java】详解网络层IP协议
PlantUML——类图(持续更新)
vue基本概念
-
原文地址:https://blog.csdn.net/m0_57021623/article/details/133281215