This time I will bring you a summary and recommendation of HTML titles. What are the precautions of HTML titles? Here are practical cases, let’s take a look.
HTML: Title
Heading is defined through tags such as
<h1> 定义最大的标题。<h6> 定义最小的标题。 <h1>This is a heading</h1> <h2>This is a heading</h2> <h3>This is a heading</h3>
Tip: The browser will automatically add blank lines before and after the title. h1 serves as the main heading (the most important), followed by h2 (the next most important), then h3, and so on. Tip: By default, HTML will automatically add an extra blank line before and after block-level elements, such as paragraphs and heading elements.
Set title alignment:
CSS syntax:
Method 1:
<!DOCTYPE html> <html> <body> <h1 style="text-align:center">This is heading 1</h1> <h2 style="text-align:left">This is heading 2</h2> <h3 style="text-align:right">This is heading 3</h3> <h4 style="text-align:justify">This is heading 4</h4> </body> </html>
Method 2:
<!DOCTYPE html> <html> <head> <style> h1 {text-align:center} h2 {text-align:left} h3 {text-align:right} </style> </head> <body> <h1>This is heading 1</h1> <h2>This is heading 2</h2> <h3>This is heading 3</h3> </body> </html>
HTML: Horizontal line
hr element can be used to separate content.
<p>This is a paragraph</p> <hr /> <p>This is a paragraph</p> <hr />
This is a paragraph
Tip: Using horizontal lines (In HTML 4.01, the align attribute of
align attribute specifies the alignment of horizontal lines.
Note: Unless the width attribute is set to less than 100%, the align attribute will have no effect.
CSS syntax (IE and Opera):
CSS syntax (Firefox, Chrome, and Safari):
CSS syntax (cross-browser):
Attribute Value Descriptioncss syntax format
align left
center
right HTML5 is not supported. HTML 4.01 is deprecated. Specifies the alignment of the
noshade noshade is not supported by HTML5. HTML 4.01 is deprecated. Specifies that the color of the
size pixels HTML5 is not supported. HTML 4.01 is deprecated. Specifies the height of the
width pixels
% HTML5 is not supported. HTML 4.01 is deprecated. Specifies the width of the
<!DOCTYPE html> <html> <body> <p>This is some text. This is some text. This is some text.</p> <hr style="width:50%;text-align:left;margin-left:0"> <p>This is some text. This is some text. This is some text.</p> </body> </html>
HTML: Comments
You can insert comments into HTML code, which can improve its readability and make the code easier to understand. The browser ignores comments and does not display them.
The comment is written like this:
Comment: The last two forward slashes (/ /) is the JavaScript comment symbol. This ensures that JavaScript will not execute the --> tag.
In addition to their obvious role in source documents, many web servers also use comments to implement features unique to document server software. These servers can scan documents for specific character sequences within traditional HTML/XHTML comments and then take appropriate actions based on commands embedded in the comments. These actions may be as simple as including text from other files (so-called server-inside include), or they may be as complex as executing other commands to dynamically generate the content of the document.
I believe you have mastered the methods after reading these cases. For more exciting information, please pay attention to other related articles on the php Chinese website!
Related reading:
Detailed explanation of examples of HTML text formatting
What are the list tags in html?
The basics of HTML editing (a must-read for beginners)
The above is the detailed content of HTML title summary recommendations. For more information, please follow other related articles on the PHP Chinese website!