
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Set the width of an image with CSS
The width property is used to set the width of an image. This property can have a value in length or in %. While giving value in %, it applies it in respect of the box in which an image is available.
Example
You can try to run the following code to set the width of an image:
<html> <head> </head> <body> <img style = "border:2px solid green; width:100px;" src = " https://www.tutorialspoint.com/images/logo.png " /> <br /> <img style = "border:2px solid green; width:50%;" src = " https://www.tutorialspoint.com/images/logo.png" /> </body> </html>
- Related Articles
- Set the width of image border with CSS
- Set the border image width with CSS
- Set the height and width of an image using percent with CSS
- Set the height of an image with CSS
- Set the opacity of an image with CSS
- Set the background image of an element with CSS
- Set the width of the outline with CSS
- Set the width of a button with CSS
- Set the width of a box with CSS
- Set border width with CSS
- Set the width of a tab character with CSS
- Set min-width and max-width of an element using CSS
- Set the width of the rule between columns with CSS
- Set the image path with CSS
- CSS border-image-width

Advertisements