HTML (Hypertext Markup Language) is a markup language used to build web pages. It is the basis for building web pages. In this article, we'll cover how to write HTML and add style and functionality to your website.
HTML documents are composed of tags, and tags can be nested. Each tag has an opening tag and a closing tag, for example:
<html> <head> <title>这是网页标题</title> </head> <body> <h1>欢迎来到我的网站</h1> <p>这是一个段落</p> </body> </html>
In this example, we have a root tag of HTML, a
tag that contains the title of the web page, and a tag, we have antag for the paragraph.
HTML tags can have attributes to specify the characteristics of the tag. For example, the tag can specify the URL of the image through the src attribute, as shown below:
<img src="https://example.com/image.jpg" alt="这是图像的描述">
In this example, we specify the URL of the image using the src attribute, and the alt attribute provides a description of the image.
In a web page, we can add links to other web pages or local files. Use the tag to create a link, for example:
<a href="https://example.com/">这是一个链接</a>
In this example, we use the href attribute to specify the URL of the link target.
We can use lists to organize information. HTML has two types of lists: ordered lists and unordered lists. Ordered lists use the
<ol> <li>第一项</li> <li>第二项</li> <li>第三项</li> </ol> <ul> <li>第一项</li> <li>第二项</li> <li>第三项</li> </ul>
In this example, we use the
We can use CSS (Cascading Style Sheets) to add styles to the website. CSS is a style sheet language used to describe the appearance and layout of web pages. For example:
<!DOCTYPE html> <html> <head> <title>这是网页标题</title> <style> h1 { color: red; font-size: 48px; } p { font-size: 24px; line-height: 1.5; } </style> </head> <body> <h1>欢迎来到我的网站</h1> <p>这是一个段落</p> </body> </html>
In this example, we embed the