What is an HTML file? The full name of HTML is hypertext marked language ". Unlike common text, an HTML file not only contains text content, but also some tags ". The suffix of an HTML file is .htm.pdf and .html. You can use a text editor to compile HTML files. Try to write an HTML file! Open your notepadand create a new file. Then, copy the file to the following code and save it as first.html. This is my first homepage.This text is boldTo view the first.html file, double-click it. Or open the browser, select open from the File menu, and then select the file.
The first tag of this file is, which tells your browser that this is the header of the HTML file. The last tag of the file is, indicating that the HTML file ends here.
The content between and is the head information. The head information is not displayed, and you cannot see it in the browser. However, this does not indicate that the information is useless. For example, you can add some keywords in the head information to help search for your webpage.
The content is the title of the file. You can see this title in the top title bar of the browser.
The information between and is the body.
InAndIn bold.As the name implies, it means bold.
An HTML file looks similar to a common text, but it has more tags than a common text, for example,These tags tell the browser how to display the file.
HTML elements are used to mark text and represent text content. For example, body, P, and title are HTML elements. HTML elements are represented by tags. tags start with <and end with>. Tags are usually paired, for example. The start is the opening tag, and the end is the closing tag. Currently, HTML tags are case-insensitive. For example, it is the same as it is. HTML elements can have attributes. Attributes can expand the capabilities of HTML elements.
For example, you can use the bgcolor attribute to make the background color of the page red, like this:
For example, you can use the border attribute to set a table to a table without borders. As follows:
Attributes are usually paired with attribute names and values, as shown in the following code: Name = "value ". In the above example, bgcolor, border is name, and red and 0 are values. Attribute values are generally marked with double quotation marks.
The attribute is usually the opening tag appended to HTML, rather than the closing tag.
In HTML, basic tags are mainly used for titles, paragraphs, and branches.
The best way to learn HTML is to follow the example. For your convenience, we have prepared a simple HTML editor. You can write HTML code on the left and click the button above to view the HTML display result.
Try it!
Example: A very simple HTML file
This example is a simple HTML file and contains only the most basic tags that can constitute an HTML file. Through this example, you can see how the browser displays the file, so as to have a first understanding of the HTML file.
Example: Simple Section
This example shows how to segment an HTML file.
Body title
This example shows how to define the body title in an HTML file.
HTML uses the
Section Division
Use <p> and </P> to divide paragraphs in HTML.
<p>This is a paragraph</p>
<p>This is another paragraph</p>
Line feed
You can use the <br> tag to wrap a line without creating a paragraph. <Br> no closing tag.
Using <p> line breaks is a bad habit. The correct method is to use <br>.
<p>This <br> is a para<br>graph with line breaks</p>
HTML comment
In an HTML file, you can write code comments and explain your code. This helps you and others better understand your code in the future.
Annotations can be written in <! Between -- and -->. The browser ignores comments. You will not see comments in the HTML body.
<!-- This is a comment -->
Some small suggestions
The HTML file automatically removes unnecessary spaces. No matter how many spaces you add, it is regarded as a space. A blank line is also considered as a space.
Some tags can separate text into segments without using <p> </P>. For example,
More examples
More paragraphs
This example shows the section features.
Line feed
This example shows how to wrap a line in an HTML file.
Body title
This example shows how to display the body title in an HTML file.
Center body title
This example shows how to center the body title.
Add a horizontal line
This example demonstrates how to add a horizontal line in an HTML file.
Code comment
This example shows how to add code comments to HTML code. These comments are only displayed in the HTML source code, but cannot be seen in the webpage formed by the source code.
Background Color
This example shows how to change the background color of an HTML file.