<!DOCTYPE html> <html> <head> <title>页面标题</title> </head> <body> 页面内容 </body> </html>
< !DOCTYPE html>
: This is the document type declaration of HTML5 and must be the first line of the document. <html>
: The root element contains the content of the entire web page. <head>
: Some elements and information need to be added, these elements include <title>
, <meta>
, <link>
, etc. <title>
: Define the title of the web page, which will be displayed on the browser tab. <body>
: Defines the main part of the web page, including most of the page content. <p>
. Here are some basic elements: <p>
: Paragraph. <a>
: Link, the href
attribute points to the URL address of the link. <img>
: Image, the src
attribute points to the URL address of the image. <header>
: Add content at the top of the web page. <footer>
: Add content to the bottom of the web page. <div>
: The document is divided into block-level areas and is the most commonly used container element in HTML. <span>
: Inline tags that can be used to add small marks to the text. <style>
tag definition. <!DOCTYPE html> <html> <head> <style> p { color: red; } </style> </head> <body> <p>这是一个红色的段落</p> </body> </html>
.css
file and reference it in the HTML using the <link>
tag . <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="样式表名称.css"> </head> <body> <p>这是一个样式表中定义的段落</p> </body> </html>
style
attribute of the HTML element. <!DOCTYPE html> <html> <head> </head> <body> <p style="color:red;">这是一个红色的段落</p> </body> </html>
<video>
: Video content, used to add videos to web pages. <audio>
: Audio content, used to add music to web pages. <canvas>
: Canvas for creating interactive graphics and animations. <input>
: Input box, used to obtain data entered by the user. <select>
: Drop-down menu used to provide option selection. The above is the detailed content of How to write html code. For more information, please follow other related articles on the PHP Chinese website!