How to use image height and width attribute in HTML Page ? Last Updated : 24 Sep, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report HTML stands for HyperText Markup Language. Hypertext defines the link between the online pages. It is used to define the text document within tag which defines the structure of websites. This language is used to annotate text in order that a machine can know it and manipulate text accordingly. Most markup languages (e.g. HTML) are human-readable. The language uses tags to define what manipulation has got to be done on the text. To add an image in an HTML page, <img> tag is used. With that, we need to use the attribute's width and height of the image in pixels. Specify both of the attributes. Syntax: <img src="url" alt="some_text"> Attribute: src: The src stands for source. Every image has an src attribute which tells the browser where to find the image you want to display. The URL of the image provided points to the location where the image is stored. alt: If the image cannot be displayed then the alt attribute acts as an alternative description for the image. The value of the alt attribute is a user-defined text. Setting width and height of Image: The width and height attributes are used to specify the width and height of an image. The attribute values are specified in pixels by default. Syntax: <img src="url" alt="some_text" width="" height=""> Note: px: pixels - pixels (1px = 1/96th of 1in) in: inches - inches (1in = 96px = 2.54cm) pt: points - points (1pt = 1/72 of 1in) Example 1: An image with a height of 600 pixels and a width of 500 pixels. The width attribute specifies the width of a picture, in points. HTML <!DOCTYPE html> <html> <body> <h2>Welcome To GFG</h2> <p>Image with width and height in points</p> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/GeeksforGeeksLogoHeader.png" alt="Welcome To GFG" width="60pt" height="80pt"> </body> </html> Output: Example 2: Another example to show the use of width and height attributes. We have mentioned width as 450 pixels and height as 220 pixels. HTML <!DOCTYPE html> <html> <body> <h2>Welcome To GFG</h2> <h3>img tag with width and height attribute</h3> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/GeeksforGeeksLogoHeader.png" alt="Welcome To GFG" width="450" height="220"> </body> </html> Output: Example 3: Another HTML program to show the use of <img> tag with width and height attribute. In this code, we have taken the value of height and width as 250 pixels. HTML <!DOCTYPE html> <html> <head> <title> Setting width and height attribute of image </title> </head> <body> <p> Image is inserted using width and height attribute in pixels. </p> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png" alt="GeeksforGeeks logo" width="250" height="250"> <p>Height of this image is 250 pixels</p> <p>Width of this image is 250 pixels</p> <p> Image is inserted using width and height attribute in points. </p> <img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png" alt="GeeksforGeeks logo" width="50pt" height="35pt"> <p>Height of this image is 50 points</p> <p>Width of this image is 35 points</p> </body> </html> Output: Comment More infoAdvertise with us Next Article How to use image height and width attribute in HTML Page ? A abhi0709singh Follow Improve Article Tags : Web Technologies HTML Blogathon Blogathon-2021 HTML-Tags HTML-Attributes HTML-Questions +3 More Similar Reads Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De 5 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read HTML Tutorial HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web. It tells the web browser how to display text, links, images, and other forms of multimedia on a webpage. HTML sets up the basic structure of a website, and then CSS and JavaScript 11 min read React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications 15+ min read React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version 7 min read JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q 15+ min read Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact 12 min read Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and 9 min read Like