Paragraphs, Line break, Horizontal rule
HTML Paragraphs
Paragraphs are defined with the <p> ... </p> tag.Paragraphs may contain text and inline elements. They are block elements, but they may not contain other block elements, including other paragraphs.
The length of the displayed text will be adjusted by the opening size of the browser.
Browsers automatically add an empty line before and after a paragraph, so, the distance between two successive paragraphs is of two lines.
- Example:
| HTML code | Displays in browser |
|---|---|
|
<html> <head> <title>Document title</title> </head> <body> <p>Paragraph 1</p> <p>Paragraph 2</p> <p>Paragraph 3</p> <p>Paragraph 4</p> </body> </html> |
Paragraph 1 Paragraph 2 Paragraph 3 Paragraph 4 |
Line Breaks
The <br /> tag inserts a line break in the content, it allows you to control where to add new line breaks, to force the beginning of a new line at a particular poinnt.- Example:
| HTML code | Displays in browser |
|---|---|
|
<html> <head> <title>Document title</title> </head> <body> <h1>Heading 1</h1> <p>Paragraph 1<br /> Line 2<br /> Line 3<br /> ... </p> <p>Paragraph 2</p> </body> </html> |
Heading 1 Paragraph 1 Paragraph 2 |
Example: <br id="idb" />
Horizontal rule
The <hr> (<hr /> for XHTML) tag creates a horizontal line in an HTML page.The <hr> element can be used to divide a web page into different horizontal areas.
The <hr> tag is a block level element, and it uses the following attributes:
- align - specifies the alignment (left, center, right)
- size - specifies the height (the thickness) of the rule in pixels
- width - the length of the rule in pixels; if you omit width, the rule runs all the way across the window
- noshade - No value; if included, it prevents the rule from having a 3-D effect
- color - sets the color of the line
- Example:
| HTML code | Displays in browser |
|---|---|
|
<html> <head> <title>Document title</title> </head> <body> <h1>Heading 1</h1> <p>Paragraph 1<br /> Line 2<br /> Line 3<br /> ... </p> <hr> Some text ... <hr color="#1111fe" size="4" width="50%"> <p>Paragraph 2</p> </body> </html> |
Heading 1 Paragraph 1 Some text ... Paragraph 2 |
Example: <hr style="width:50%; height:4px; color:#1111fe" />
HTML Headings and Comments <<-- Previous ----------- Next -->> HTML Text Formatting