- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - poster Attribute
The HTML poster attribute is used to specify an image/poster for the video. It is displayed while the video is downloading or until the user clicks the play button.
If this attribute is not specified then nothing is displayed until the first frame is available, then the first frame is shown as a poster frame for the video.
Syntax
Following is the syntax of the HTML poster attribute
<video poster = "posterlocation/url"></video>
Where the poster location can be the location of your local image/poster or any URL.
Example
In the following example, we are using the HTML 'poster' attribute within the video element to specify an image/poster to the video until the user does not click on the play button.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML 'poster' attribute</title> <style> video { border: 3px solid rgb(86, 3, 3); } </style> </head> <body> <!--HTML 'poster' attribute--> <p>Example of the HTML 'poster' attribute</p> <video poster="Asset-2PPT_.png" width="400" height="250" controls> <source src="https://static.videezy.com/system/resources/previews/000/019/695/original/pointing-pink.mp4"> </video> </body> </html>
When we run the above code, it will generate an output consisting of the video displayed on the webpage.
Example
Consider the another scenario, where we are going to use the poster attribute with the video element and specify the poster while the video is downloading.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML 'poster' attribute</title> <style> video { border: 3px solid rgb(86, 3, 3); } </style> </head> <body> <!--HTML 'poster' attribute--> <p>Example of the HTML 'poster' attribute</p> <video poster="Asset-2PPT_.png" width="400" height="250" controls> <source type="video/mp4" src="https://static.videezy.com/system/resources/previews/000/019/695/original/pointing-pink.mp4"> </video> </body> </html>
On running the above code, the output window will pop up displaying the video onthe webpage.
Example
Let's look at the following example, where we are going to run the script using the poster attribute and also using the separate function to set and remove the poster.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML 'poster' attribute</title> <style> video { border: 5px solid rgb(123, 9, 200); } button { padding: 7px; } </style> </head> <body> <!--HTML 'poster' attribute--> <p>Example of the HTML 'poster' attribute</p> <video width="400" height="250" controls id='demo'> <source type="video/mp4" src="Fix battleground mobile india name is already taken problem solved - bgmi.mp4"> </video> <br> <button onclick="Add()">Set poster</button> <button onclick="Remove()">Remove poster </button> <script> function Add() { document.getElementById('demo').poster = "download.png"; } function Remove() { document.getElementById('demo').poster = ""; } </script> </body> </html>
On executing the above script, the output window will pop up displaying the video along with a click buttons on the webpage. when the user tries to click the button the event gets triggered and perform respective action.
To Continue Learning Please Login
Login with Google