` tag is used to specify the horizontal alignment of the text within a paragraph. > **β οΈ Deprecation Notice:** This attribute is **deprecated** in HTML 4.01 and is **not supported** in HTML5. Modern web development standards require using CSS instead of this attribute to control text alignment. --- ## Quick Example Here is how the `align` attribute was traditionally used to align paragraph text to the right: ```html
This paragraph is aligned to the right.
``` --- ## Browser Support | Browser | Supported | | :--- | :--- | | **Internet Explorer** | Yes | | **Firefox** | Yes | | **Opera** | Yes | | **Google Chrome** | Yes | | **Safari** | Yes | *Note: While all major browsers historically supported and may still render this attribute for backwards compatibility, relying on it is highly discouraged.* --- ## Syntax ```htmlParagraph content...
``` ### Attribute Values | Value | Description | | :--- | :--- | | `left` | Left-aligns the text (default behavior for left-to-right languages). | | `right` | Right-aligns the text. | | `center` | Centers the text horizontally. | | `justify` | Stretches the lines so that each line has equal width (similar to newspaper and magazine layouts). | --- ## Modern Alternative: CSS `text-align` Because the `align` attribute is obsolete in HTML5, you should use the CSS `text-align` property instead. This keeps your presentation layer (CSS) separate from your content structure (HTML). ### CSS Syntax ```htmlThis paragraph is aligned to the right using inline CSS.
``` ### Comparison Examples #### 1. Center Alignment * **Deprecated HTML:** ```htmlThis text is centered.
``` * **Modern CSS:** ```htmlThis text is centered.
``` #### 2. Justified Text * **Deprecated HTML:** ```htmlThis text is justified across the width of the container.
``` * **Modern CSS:** ```htmlThis text is justified across the width of the container.
``` --- ## Best Practices For clean and maintainable code, avoid inline styles and define your text alignment in an external CSS stylesheet: ```css /* External Stylesheet (style.css) */ .text-left { text-align: left; } .text-center { text-align: center; } .text-right { text-align: right; } .text-justify { text-align: justify; } ``` ```htmlThis paragraph is centered using an external CSS class.
```
YouTip