📅  最后修改于: 2023-12-03 15:01:08.816000             🧑  作者: Mango
HTML (Hypertext Markup Language) is the standard markup language used for creating web pages and web applications. It allows developers to structure content on a web page using a combination of tags and attributes. HTML code is read and interpreted by web browsers, which use the information to display the content on a user's device.
A basic HTML document has the following structure:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Heading 1</h1>
<p>This is a paragraph.</p>
</body>
</html>
The <!DOCTYPE html>
declaration at the beginning informs the browser that the document is an HTML5 document, which is the current version of HTML. The <html>
element is the container for all other HTML elements, and the <head>
element contains metadata about the document such as the page title. The content of a web page goes inside the <body>
element, which contains various HTML elements that form the visual components of the page.
HTML tags are used to identify different types of content on a web page. Each tag consists of a tag name enclosed in angle brackets, and can have one or multiple attributes, each with a value. Some common HTML tags include:
<h1>
- <h6>
: Headings, with <h1>
being the largest and most important heading, and <h6>
being the smallest and least important.<p>
: Paragraphs of text.<a>
: Links to other web pages.<img>
: Images displayed on the page.<ul>
and <ol>
: Unordered and ordered lists, respectively.<div>
: A container for page elements that can be styled using CSS.<table>
: A table containing rows and columns of data.HTML attributes provide additional information about an element. They are added to an opening tag using the following syntax:
<tagname attribute1="value1" attribute2="value2">
Some commonly used attributes include:
id
: A unique identifier for an element, which can be used to target it with CSS or JavaScript.class
: A way to group multiple elements together for styling purposes.src
: Specifies the source for an image, audio, or video file.href
: Specifies the URL for a link.HTML is a fundamental technology for creating web pages and web applications. Understanding how to structure content using HTML tags and attributes is an essential skill for web developers. By combining HTML with CSS and JavaScript, developers can create modern and interactive web pages that provide a great user experience.