Home > Article > Web Front-end > How to write html files
To write an HTML file, follow these steps: Create a text file Declare the HTML version Create the HTML root element Create the head element Create the body element Add the element Close element Save the file (extension .html)
How to write HTML files
HTML (Hypertext Markup Language) is a markup language used to create web pages. To write an HTML file, you need to follow these steps:
1. Create a text file
Create a new file using a text editor such as Notepad or Sublime Text .
2. Declaring the HTML version
Add the following line at the top of the file:
<code class="html"><!DOCTYPE html></code>
This tells the browser which HTML version is being used.
3. Create the HTML root element
Add the following line after the <DOCTYPE>
declaration:
<code class="html"><html></code>
This is The HTML root element that contains all other elements.
4. Create the header element
The header element contains metadata about the web page, such as the title and style. Add the following line inside the <html>
element:
<code class="html"><head> <title>网页标题</title> </head></code>
5. Create the body element
The body element contains the content of the web page. Add the following line after the <head>
element:
<code class="html"><body> </body></code>
6. Add the element
after the <body>
HTML elements are added inside the element to create page content. For example, to add a title, you would add the following line:
<code class="html"><h1>标题文本</h1></code>
7. Closing elements
Make sure that all open elements are closed properly. After adding all the content, close the <body>
and <html>
elements:
<code class="html"></body> </html></code>
8. Save the file
Save the file with the extension .html
. For example, you could name it index.html
.
Sample HTML file
<code class="html"><!DOCTYPE html> <html> <head> <title>我的第一个网页</title> </head> <body> <h1>欢迎来到我的网页!</h1> <p>这是我的第一个 HTML 文件。</p> </body> </html></code>
Tip:
The above is the detailed content of How to write html files. For more information, please follow other related articles on the PHP Chinese website!