# HTML `
![]()
` border Attribute
The `border` attribute of the `
![]()
` tag is used to specify the width of the border around an image.
> **β οΈ Deprecation Notice:** This attribute is **deprecated** in HTML 4.01 and is **not supported** in HTML5. Modern web development standards require using CSS to style image borders instead.
---
## Quick Example
The following code defines an image with a 5-pixel border using the legacy HTML attribute:
```html

```
---
## Browser Support
| Browser | Support Status |
| :--- | :--- |
| **Internet Explorer** | Supported |
| **Firefox** | Supported |
| **Opera** | Supported |
| **Google Chrome** | Supported |
| **Safari** | Supported |
*Note: While all major browsers still support this attribute for backwards compatibility, relying on it is highly discouraged.*
---
## Definition and Usage
The `border` attribute defines the width of the border surrounding an image in pixels.
### Key Behaviors:
* **Default Border:** By default, images do not have a border unless they are nested inside an anchor (`
`) element (acting as a link). In older browsers, images wrapped in links automatically display a blue border.
* **Removing Link Borders:** Historically, developers set `border="0"` on images inside links to prevent browsers from rendering this default blue border.
---
## Syntax
```html
```
### Attribute Values
| Value | Description |
| :--- | :--- |
| *pixels* | Specifies the width of the border in pixels (e.g., `5`, `0`). |
---
## Modern Alternative: CSS Borders
Because the `border` attribute is obsolete in HTML5, you should always use CSS to style image borders. CSS offers significantly more control over the border's style, color, and width.
### CSS Syntax:
```html
```
### Comparison: HTML vs. CSS
#### 1. Legacy HTML Method (Deprecated)
This method only allows you to set the border width. The border color defaults to the text color of the document (or blue if the image is a link).
```html
```
#### 2. Modern CSS Method (Recommended)
With CSS, you can define the width, style (solid, dashed, dotted, double, etc.), and color in a single rule.
```html
```