YouTip LogoYouTip

Att Img Vspace

# HTML <img> vspace Attribute The `vspace` attribute of the `` tag is used to specify the vertical spacing (margins) above and below an image. > **⚠️ Deprecation Notice:** The `vspace` attribute is **deprecated** in HTML 4.01 and is **not supported** in HTML5. Modern web development practices require using CSS instead to control layout and spacing. --- ## Quick Example The following example demonstrates an image with a vertical margin of 50 pixels at both the top and bottom: ```html

Smiley face This is some text. This is some text. This is some text.

``` --- ## Browser Support The `vspace` attribute is supported by all major legacy browsers: * Internet Explorer * Firefox * Opera * Google Chrome * Safari *Note: While modern browsers may still render this attribute for backward compatibility with legacy websites, you should not use it in new projects.* --- ## Definition and Usage The `vspace` attribute defines the amount of white space (in pixels) to be added to the top and bottom of an image. ### Syntax ```html ``` ### Attribute Values | Value | Description | | :--- | :--- | | *pixels* | Specifies the vertical space above and below the image in pixels. | --- ## Modern Alternative: CSS Margins Because the `vspace` attribute is deprecated, you should use the CSS `margin` property to achieve the same visual effect. This keeps your presentation layer (CSS) separate from your content structure (HTML). ### CSS Equivalent Syntax To add vertical spacing of 50 pixels to the top and bottom of an image, use the following CSS: ```html Smiley face ``` ### Comparison Example Below is a comparison showing the legacy HTML approach versus the modern CSS approach: #### Legacy HTML Approach (Not Recommended) ```html Company Logo ``` #### Modern CSS Approach (Recommended) ```html Company Logo Company Logo ```
← Att Img WidthAtt Img Usemap β†’