YouTip LogoYouTip

Att Object Hspace

# HTML hspace Attribute The `hspace` attribute of the `` element is a legacy HTML attribute used to specify the horizontal spacing (margins) on the left and right sides of an embedded object. --- ## Deprecation Notice > ⚠️ **Important:** The `hspace` 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 layout and spacing. To achieve the same effect, use the CSS `margin-left` and `margin-right` properties (or the shorthand `margin` property). --- ## Browser Support | Attribute | Internet Explorer | Firefox | Opera | Google Chrome | Safari | | :--- | :--- | :--- | :--- | :--- | :--- | | **hspace** | Yes | Yes | Yes | Yes | Yes | *Note: While major browsers historically supported this attribute for backward compatibility, relying on it in modern web applications is highly discouraged.* --- ## Definition and Usage The `hspace` attribute defines the amount of whitespace (in pixels) to be inserted to the left and right of an `` element. This helps separate the embedded object (such as a flash file, PDF, or applet) from surrounding text or other inline elements. --- ## Syntax ```html ``` ### Attribute Values | Value | Description | | :--- | :--- | | *pixels* | Specifies the horizontal spacing on the left and right sides of the object in pixels. | --- ## Code Examples ### Legacy HTML Example (Deprecated) The following example demonstrates how the `hspace` attribute was traditionally used to add 100 pixels of horizontal space to both sides of an object: ```html

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

``` --- ### Modern CSS Alternative (Recommended) To achieve the exact same visual layout in modern, standards-compliant HTML5, you should use the CSS `margin` property. #### Inline CSS Example: Using inline styles to apply a 100-pixel horizontal margin (left and right) and 0-pixel vertical margin (top and bottom): ```html

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

``` #### External/Internal CSS Example: For cleaner code separation, define the styles in your stylesheet: ```html

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

```
← Att Object NameAtt Object Height β†’

YouTip © 2024-2026 | Home | Learn Technology, Build Dreams!

All content is for educational and learning purposes only.