How To Set Height And Width Of An Image In HTML
Posted 2025-04-21 09:55:05
0
96

To set the height and width of an image in HTML, you can do it in several ways. Here are the most common ones:
Option 1: Inline with HTML Attributes
<img src="image.jpg" width="300" height="200" alt="Description">
Option 2: Using Inline CSS
<img src="image.jpg" style="width: 300px; height: 200px;" alt="Description">
Option 3: Using a CSS Class
<style>
.custom-img {
width: 300px;
height: 200px;
}
</style>
<img src="image.jpg" class="custom-img" alt="Description">
Notes:
-
Always include the
alt
attribute for accessibility and SEO. -
Use
object-fit: cover;
in CSS if you want the image to maintain aspect ratio and fill the space.
Need help with making it responsive or maintaining aspect ratio too?
Search
Sellect from all Categories bellow ⇓
- Artificial Intelligence (AI)
- Cybersecurity
- Blockchain & Cryptocurrencies
- Internet of Things
- Cloud Computing
- Big Data & Analytics
- Virtual Reality
- 5G & Future Connectivity
- Robotics & Automation
- Software Development & Programming
- Tech Hardware & Devices
- Tech in Healthcare
- Tech in Business
- Gaming Technologies
- Tech in Education
- Machine Learning (ML)
- Blogging
- Affiliate Marketing
- Make Money
- Digital Marketing
- Product Review
- Social Media
- Excel
- Graphics design
- Freelancing/Consulting
- FinTech (Financial Technology)
- E-commerce and Digital Marketing
- Business
- Sport
- Self Development
- Tips to Success
- Video Editing
- Photo Editing
- Website Promotion
- YouTube
- Lifestyle
- Health
- Computer
- Phone
- Music
- Accounting
- Causes
- Networking
Read More
How Build a mindset for wealth
Building a mindset for wealth requires...
The Role of Emotional Intelligence in Leadership
Emotional intelligence (EI) is a crucial factor...
How to Make Money from Facebook – A Step-by-Step Guide
Facebook offers numerous ways to earn money,...
How to Create SEO for YouTube
Creating SEO for YouTube involves optimizing...
How to Make Money on WhatsApp: A Step-by-Step Guide
Making money from WhatsApp can be highly...