`. This declaration tells the browser this"/> `. This declaration tells the browser this">
Home >Web Front-end >Front-end Q&A >How to write html code
<!DOCTYPE html>
. This declaration tells the browser which document type definition (DTD) this document adopts. Followed by the <html>
tag, used to indicate the beginning and end of the web page. Within the <html>
tag, there are usually two important sub-tags: <head>
and <body>
.
<ul>
<li>
<head>
Tag: The content inside it will not be displayed directly in the browser, but is mainly used to provide metadata for the page. It can include <title>
tags (used to set the title of the web page) and <meta>
tags (used to set the keywords, description and other information of the web page), etc.
<li>
<body>
Tags: This is the main part of the page and contains the HTML tags for the web content.
<p>The following is a basic HTML structure code:
<!DOCTYPE html> <html> <head> <title>我的网页标题</title> <meta charset="utf-8"> </head> <body> 这里是内容 </body> </html>
<p>
tag, which represents a paragraph.
<p>这是一个段落。</p><p>In the above code, the text in the
<p>
tag "This is a paragraph." is the text content of a paragraph. At the same time, HTML also provides multiple levels of titles (h1, h2, h3...h6)
to enhance the layering and structure of the article.
<h1>这是一个一级标题。</h1> <h2>这是一个二级标题。</h2>
<img>
tag to insert images. .
<img src="图片路径" alt="图片描述"><p>Among them, the
src
attribute is required and is used to specify the URL or relative file path of the image file. The alt
attribute is used to display a text on the page to describe the content of the image when the image cannot be displayed.
<a>
tag to create a link. . The
<a href="http://www.example.com">这是一个链接</a><p>
href
attribute is required and is used to specify the target URL of the link. At the same time, you can also add the title
attribute in the <a>
tag to add prompt information when the mouse hovers.
<p>If you want to link to other HTML documents in the same directory, you can also use relative paths:
<a href="./about.html">关于我们</a>
<ul>
and <li>
tags to create an unordered list, use the <ol>
and <li>
tags to create an ordered list.
<ul> <li>列表项1</li> <li>列表项2</li> <li>列表项3</li> </ul> <ol> <li>列表项1</li> <li>列表项2</li> <li>列表项3</li> </ol>
<table>
, <tr>
, <th>
and <td>
tags to create a table.
<table> <tr> <th>姓名</th> <th>年龄</th> <th>性别</th> </tr> <tr> <td>张三</td> <td>18</td> <td>男</td> </tr> <tr> <td>李四</td> <td>22</td> <td>女</td> </tr> </table><p>Among them,
<th>
label represents the header cell, <td>
label represents the data cell, <tr># The ## label represents a row, and the
<table> label represents the entire table.