HTML Img Width Attribute - Dofactory
Có thể bạn quan tâm
- SQL
SQL Tutorial SQL Reference Connection Strings
- .NET
C# Design Patterns C# Coding Standards C# Code Examples Visual Studio Shortcut Keys
- HTML
HTML Tutorial HTML Reference
- CSS
CSS Tutorial CSS Reference
- JavaScript
JavaScript Tutorial JavaScript Design Patterns
- SQL
- .NET
- HTML
- CSS
- JavaScript
Select tutorial
Select tutorial
Select tutorial
Select tutorial
Select tutorial
Back to HTML Select Tutorial - HTML Tutorial
- HTML Reference
- CSS Tutorial
- CSS Reference
- SQL Tutorial
- SQL Reference
- JavaScript Tutorial
- JavaScript Patterns
- C# Design Patterns
- C# Coding Standards
- Connection Strings
- Visual Studio Shortcuts
The width attribute on an <img> tag sets the width of the image.
The width is specified in pixels -- without the ‘px‘ unit.
Example
#
A width attribute on an <img> element. The width attribute overrides the original image width.
<img src="/img/html/poppies.jpg" width="315"
alt="Poppies, by Van Gogh" />
Try it live Using width
#
The width attribute specifies the width of the image element.
The width is defined in pixels, without the 'px' unit.
To define the width in % or other unit, use the CSS width property.
The browser will maintain the correct aspect ratio of the image if the height attribute is not set.
Note: Image width can also be defined with CSS. If both the width attribute and CSS width property are specified, CSS takes precedence (wins).
Tip: The browser must perform an image resize if the specified width is different from the original image. To speed up the page, it is best to specify the real image size.
Syntax
#
<img width="pixels" />Values
#
| Value | Description |
|---|---|
| pixels | A number (e.g. 200). |
Browser support
#
Here is when width support started for each browser:
Chrome | 1.0 | Sep 2008 |
Firefox | 1.0 | Sep 2002 |
IE/Edge | 1.0 | Aug 1995 |
Opera | 1.0 | Jan 2006 |
Safari | 1.0 | Jan 2003 |
You may also like
#
- Our HTML img Tag Reference
- Our HTML width Attribute Reference
- Our CSS width Property Reference
- Our CSS Images Tutorial
Jack Poorte Last updated on Sep 30, 2023 Earn income with your HTML skills Sign up and we'll send you the best freelance opportunities straight to your inbox. We're building the largest freelancing marketplace for people like you. Send Me Opportunities By adding your name & email you agree to our terms, privacy and cookie policies. Guides - HTML Tables
- HTML Images
- HTML Color Names
- HTML Links
- HTML Tags
- HTML Lists
- HTML Forms
- HTML Buttons
- HTML Spaces
- HTML Checkboxes
- HTML Editors
- HTML Comments
- width Attribute
- Example
- Using width
- Syntax
- Values
- Browser support
- You may also like
Từ khóa » Html Image Original Width
-
HTML DOM Image NaturalWidth Property - W3Schools
-
How To Get Original Image Size (Width & Height) In JavaScript
-
CSS Image Max-width Set To Original Image Size? - Stack Overflow
-
How To Resize An Image In HTML?
-
HTML Tag: Change The Width Of A Picture In HTML »
-
HTML Img Width Attribute - W3Schools
-
Setting Height And Width On Images Is Important Again
-
Width And Height Of An Image - HTML Tags - TAG Index
-
How To Keep Dimensions Css Image Code Example - Code Grepper
-
How To Set The Width And Height Of An Image Using HTML
-
HTML Tutorial => Image Width And Height
-
C37: Using CSS Max-width And Height To Fit Images
-
How To Get Image Size Using JavaScript - W3docs
-
How To Resize An Image With HTML - Computer Hope
Chrome
Firefox
IE/Edge
Opera
Safari