- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Set the width of the element in HTML
Use the width attribute in HTML to set the width of an element. You can use the attribute with the following elements − <canvas>, <embed>, <img>, <input>, <video>, etc.
Example
You can try to run the following code to implement width attribute in HTML −
<!DOCTYPE HTML> <html> <body> <video width="300" height="200" controls autoplay> <source src = "/html5/foo.ogg" type = "video/ogg" /> <source src = "/html5/foo.mp4" type = "video/mp4" /> Your browser does not support the video element. </video> </body> </html>
Output
- Related Articles
- How to set the width of an element in JavaScript?
- Set the width of an element to 25% in Bootstrap
- Set the width of an element to 100% in Bootstrap
- Set the width of an element to 75% in Bootstrap
- Set the width of an element to 50% in Bootstrap 4
- Set min-width and max-width of an element using CSS
- How to set the maximum width of an element with JavaScript?
- How to set the minimum width of an element with JavaScript?
- How to set the name of the element in HTML?
- How to set table width in HTML?
- How to set the width of the outline around an element with JavaScript?
- How do we set the type of element in HTML?
- Set the name of the form the element belongs to in HTML?
- How to set the width of an element's border with JavaScript?
- How to set cell width and height in HTML?

Advertisements