HTML title para...LOGIN

HTML title paragraph

HTML Heading

In HTML documents, headings are important.

Heading is defined through tags such as <h1> - <h6>.

<h1> Defines the largest title. <h6> Define the smallest title.


Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>php.cn</title>
</head>
<h1>这是标题 1</h1>
<h2>这是标题 2</h2>
<h3>这是标题 3</h3>
<h4>这是标题 4</h4>
<h5>这是标题 5</h5>
<h6>这是标题 6</h6>
</body>
</html>

Program running result:

2.png

Comments: The browser will automatically add blank lines before and after the title.

Note: By default, HTML will automatically add an extra blank line before and after block-level elements, such as paragraphs and heading elements.


Heading is important

##Please make sure to use the HTML heading tag only in the title. Don’t use headings just to produce bold or large text.

Search engines use headers to index the structure and content of your web pages.

Because users can quickly navigate your web page through headings, it is important to use headings to present the structure of your document.

H1 should be used as the main heading (the most important), followed by h2 (the next most important), then h3, and so on.


HTML horizontal line

##<hr /> tag in HTML Creates a horizontal line on the page. The

hr element can be used to separate content.


Example

##The following code will output the title and horizontal line

<!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <title>php.cn</title>
 </head>
 <body>
 
 <h1>这是第一个标题</h1>
 <hr/>
 <h2>这是第二个标题</h2>
 <hr/>
 
 </body>
 </html>

Program running results:

6.pngThe above code outputs the <h1> title and <h6> title, There are also two horizontal lines



HTML Paragraph

Paragraphs are defined through the <p> tag.

Look directly at the example

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>php.cn</title>
</head>
<body>
<p>这是第一个段落。</p>
<p>这是第二个段落。</p>
</body>
</html>

Program running result:

This is the first paragraph.

This is the second paragraph.

Note

: The browser will automatically add blank lines before and after the paragraph. (<p> is a block-level element)

Tip: It is a bad habit to use empty paragraph tags <p></p> to insert a blank line. Replace it with the <br /> tag! (But don’t use the <br /> tag to create a list. Don’t worry, you’ll learn about HTML lists later.)


Don’t forget the closing tag

Even if you forget to use the closing tag, most browsers will display the HTML correctly, like this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>php.cn</title>
</head>
<body>
<p>忘记了结束标签
<p>忘记了结束标签
</body>
</html>

Program running result:

Forgot the end tag

Forgot the end tag

#The above example will work fine in most browsers, but don’t rely on this approach. Forgetting to use closing tags can produce unexpected results and errors.

Note: In a future version of HTML, omitting the closing tag will not be allowed.

Tip: Closing HTML with a closing tag is a future-proof way to write HTML. Clearly marking where an element begins and ends makes your code easier to understand, both for you and the browser.


##HTML Line Break

If you wish to create a new paragraph without To perform a line break (new line), use the <br /> tag

The<br /> element is an empty HTML element. Since a closing tag doesn't make any sense, it doesn't have a closing tag.

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>php.cn</title>
</head>
<body>
<p>
    如果<br />需要<br />换行<br />段落,<br />请使用 br 标签.
</p>
</body>
</html>

Program running result:

IfNeed
Line break
paragraph,
please use br tag.


##HTML spaces

Normally, HTML will automatically cut off excess spaces. No matter how many spaces you add, they are all counted as one space. For example, if you add 10 spaces between two words, HTML will truncate 9 spaces and keep only one. To add spaces to a web page, you can use

 

; to represent spaces.

Example
Using spaces in source code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>php.cn</title>
</head>
<body>

<h1>春晓</h1>

 <p>春眠不觉晓,</p>
     <p>处处闻啼鸟。</p>
        <p>夜来风雨声,</p>
            <p>花落知多少。</p>

<p>注意,浏览器忽略了源代码中的排版<br/>(省略了多余的空格和换行)。</p>
</body>
</html>

Program running results:

7.png

The following uses   to represent spaces.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>php.cn</title>
</head>
<body>
<h1>春晓</h1>
<p>春眠不觉晓,</p>
<p>&nbsp&nbsp&nbsp&nbsp处处闻啼鸟。</p>
<p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp夜来风雨声,</p>
<p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp花落知多少。</p>
<p>使用了&nbsp空格</p>
</body>
</html>

Program running result:

5.png

Tips:  represents a space



Next Section
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>php.cn</title> </head> <body> <h1>春晓</h1> <p>春眠不觉晓,</p> <p>&nbsp&nbsp&nbsp&nbsp处处闻啼鸟。</p> <p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp夜来风雨声,</p> <p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp花落知多少。</p> <p>使用了&nbsp空格</p> </body> </html>
submitReset Code
ChapterCourseware