YouTip LogoYouTip

Att Hr Align

# HTML <hr> align Attribute The `align` attribute of the `
` tag is used to specify the horizontal alignment of a thematic break (horizontal rule) on a web page. --- ## Quick Example The following code demonstrates how to align a horizontal rule to the left and set its width to 50%: ```html

This is some paragraph text. This is some paragraph text.


``` --- ## Definition and Usage The `align` attribute specifies the alignment of a `
` element. > **Important Note:** The `align` attribute has no visible effect unless the `width` attribute of the `
` element is set to less than 100%. ### Deprecation Notice * **HTML5 does not support the `
` `align` attribute.** You should use CSS to style and align horizontal rules instead. * In HTML 4.01, the `align` attribute of the `
` element was **deprecated**. --- ## Browser Support The `align` attribute is supported by all major legacy browsers, including Internet Explorer, Firefox, Opera, Google Chrome, and Safari. However, modern web standards require using CSS instead of this attribute. --- ## Syntax ```html
``` ### Attribute Values | Value | Description | | :--- | :--- | | `left` | Aligns the horizontal rule to the left. | | `center` | Aligns the horizontal rule to the center (Default value). | | `right` | Aligns the horizontal rule to the right. | --- ## Modern CSS Alternatives (Cross-Browser Compatibility) Since the `align` attribute is deprecated in HTML 4.01 and obsolete in HTML5, you should use CSS to align `
` elements. Historically, different browsers handled `
` alignment differently using CSS: * **Internet Explorer & Opera:** Used `text-align` on the parent or the element itself. * **Firefox, Chrome, & Safari:** Used margin properties (`margin-left`, `margin-right`). ### Cross-Browser CSS Solutions To ensure consistent styling across all modern browsers, use the `margin` property to align your `
` element. #### 1. Left Aligning a `
` with CSS To align the horizontal rule to the left, set the left margin to `0` and the right margin to `auto`: ```html
``` #### 2. Right Aligning a `
` with CSS To align the horizontal rule to the right, set the right margin to `0` and the left margin to `auto`: ```html
``` #### 3. Centering a `
` with CSS (Default) To center the horizontal rule, set both the left and right margins to `auto`: ```html
```
← Att Hr NoshadeAtt Frame Src β†’