Center and br Tags

Center and br Tags

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
  1. Introduction to HTML
  2. HTML document structure
  3. Creating an HTML document
  4. Containers and empty elements
HTML Elements
  1. HTML, HEAD, TITLE, BODY
  2. Attributes of Body Element: Background, Bgcolor, Text, Link, Alink, Vlink, Leftmargin, Topmargin
  3. FONT (Attributes of FONT Element: Color, Size, Face)
  4. IMG (Attributes of IMG Element: Src, Width, Height, Alt, Align)
  5. BASEFONT (Attributes of BASEFONT Element: Color, Size, Face)
  6. CENTER, BR
  7. HR (Attributes of HR Element: Width, Align, Noshade, Color, Size, Face)
  8. H1-H6 (Heading Elements)
  9. P (Paragraph), B (Bold), I (Italics), U (Underline)
  10. UL (Unordered List) Attributes of UL: Type 
  11. OL (Ordered List) Attributes of OL: Type, Start
  12. Linking Internal and External Linking
  13. A (Anchor) Attributes of A Element: Href, Title, Name, Alt
  14. TABLE (Attributes of TABLE Element: Td, Th, Tr)