- HTML Tutorial
- HTML - Home
- HTML - Introduction
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- 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 Color Names & Values
- HTML - Color Names
- 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 Picker
- HTML References
- HTML - Cheat Sheet
- 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
HTML poster attribute is used to specify an image/poster(thumbnail) for the video to be displayed 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
<video poster = "posterlocation/url"></video>
Where the poster location can be the location of your local image/poster or any URL.
Applies On
Below listed elements allow using of the HTML placeholder attribute
Element | Description |
---|---|
<video> | HTML <video> tag is used to render video on webpage. |
Examples of HTML poster Attribute
Below examples will illustrate the HTML poster attribute, where and how we should use this attribute!
Set poster for a video
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> <h3>Example of the HTML 'poster' Attribute</h3> <video poster= "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRF50DmcEaJHWoz35nvXG7nirVaCNVqymt6Xw&s" width="400" height="250" controls> <source src= "https://static.videezy.com/system/resources/previews/000/019/695/original/pointing-pink.mp4" > </video> <p>You can notice that a black logo is displayed before playing video</p> </body> </html>
Set poster using script
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> <h3>Example of the HTML 'poster' Attribute</h3> <video width="400" height="250" controls id='demo'> <source type="video/mp4" src="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>
Supported Browsers
Attribute | |||||
---|---|---|---|---|---|
poster | Yes 4.0 | Yes 9.0 | Yes 3.5 | Yes 4.0 | Yes 10.5 |
To Continue Learning Please Login
Login with Google