
HTML (HyperText Markup Language) provides various tags to format and structure web content. Among them, the <center> and <br> tags play significant roles in text formatting. In this article, we will explore their usage, examples, and outputs.
The <center> Tag
The <center> tag was previously used to align text or elements at the center of a webpage. However, it has been deprecated in HTML5, and it is recommended to use CSS (text-align: center;) instead.
Example of <center> Tag
<html>
<head>
<title>Center Tag Example</title>
</head>
<body>
<center>
<h2>This text is centered</h2>
<p>All elements inside the <center> tag are aligned to the center.</p>
</center>
</body>
</html>
Output:
The heading and paragraph text will appear centered on the webpage.
The <br> Tag
The <br> tag is a self-closing tag in HTML used to insert line breaks within text content. Unlike the <p> tag, which creates separate paragraphs, <br> simply moves the content to the next line without adding extra spacing.
Example of <br> Tag
<html>
<head>
<title>BR Tag Example</title>
</head>
<body>
<p>This is the first line.<br>This is the second line.<br>This is the third line.</p>
</body>
</html>
Output:
This is the first line.
This is the second line.
This is the third line.
The <br> tag is particularly useful when formatting addresses, poetry, or any text that requires manual line breaks.
UNIT-205
HTML Fundamentals
HTML Elements
HTML Fundamentals
HTML Elements
- HTML, HEAD, TITLE, BODY
- Attributes of Body Element: Background, Bgcolor, Text, Link, Alink, Vlink, Leftmargin, Topmargin
- FONT (Attributes of FONT Element: Color, Size, Face)
- IMG (Attributes of IMG Element: Src, Width, Height, Alt, Align)
- BASEFONT (Attributes of BASEFONT Element: Color, Size, Face)
- CENTER, BR
- HR (Attributes of HR Element: Width, Align, Noshade, Color, Size, Face)
- H1-H6 (Heading Elements)
- P (Paragraph), B (Bold), I (Italics), U (Underline)
- UL (Unordered List) Attributes of UL: Type
- OL (Ordered List) Attributes of OL: Type, Start
- Linking Internal and External Linking
- A (Anchor) Attributes of A Element: Href, Title, Name, Alt
- TABLE (Attributes of TABLE Element: Td, Th, Tr)