HTML Topics
- HTML Intro
- HTML Basic
- HTML Editors
- HTML CSS
- HTML Tags
- HTML Deprecated Tags
- HTML Events
- HTML Event Attributes
- HTML Global Attributes
- HTML Attributes
- abbr
- accept
- accept-charset
- accesskey
- action
- align
- alt
- archive
- as
- async
- autocapitalize
- autocomplete
- autofocus
- autoplay
- axis
- bgcolor
- border
- cellpadding
- cellspacing
- char
- charoff
- charset
- checked
- cite
- class
- classid
- codebase
- codetype
- color
- cols
- colspan
- compact
- content
- contenteditable
- controls
- coords
- crossorigin
- data
- data-*
- datetime
- declare
- default
- defer
- dir
- dirname
- disabled
- download
- draggable
- enctype
- enterkeyhint
- for
- form
- formaction
- formenctype
- formmethod
- formnovalidate
- formtarget
- frame
- frameborder
- frameset
- headers
- height
- hidden
- high
- href
- hreflang
- hspace
- http-equiv
- id
- inert
- inputmode
- ismap
- kind
- label
- lang
- list
- loop
- low
- max
- maxlength
- media
- method
- min
- multiple
- muted
- name
- novalidate
- onabort
- onafterprint
- onbeforeprint
- onbeforeunload
- onblur
- oncanplay
- oncanplaythrough
- onchange
- onclick
- oncontextmenu
- oncopy
- oncuechange
- oncut
- ondblclick
- ondrag
- ondragend
- ondragenter
- ondragleave
- ondragover
- ondragstart
- ondrop
- ondurationchange
- onemptied
- onended
- onerror
- onfocus
- onhashchange
- oninput
- oninvalid
- onkeydown
- onkeypress
- onkeyup
- onload
- onloadeddata
- onloadedmetadata
- onloadstart
- onmousedown
- onmousemove
- onmouseout
- onmouseover
- onmouseup
- onmousewheel
- onoffline
- ononline
- onpagehide
- onpageshow
- onpaste
- onpause
- onplay
- onplaying
- onpopstate
- onprogress
- onratechange
- onreset
- onresize
- onscroll
- onsearch
- onseeked
- onseeking
- onselect
- onstalled
- onstorage
- onsubmit
- onsuspend
- ontimeupdate
- ontoggle
- onunload
- onvolumechange
- onwaiting
- onwheel
- open
- optimum
- pattern
- placeholder
- popover
- popovertarget
- popovertargetaction
- poster
- preload
- readonly
- rel
- required
- reversed
- rows
- rowspan
- sandbox
- scope
- selected
- shape
- size
- sizes
- span
- spellcheck
- src
- srcdoc
- srclang
- srcset
- start
- step
- style
- tabindex
- target
- title
- translate
- type
- usemap
- value
- width
- wrap
- HTML Comments
- HTML Entity
- HTML Head
- HTML Form
- HTML IndexedDB
- HTML Drag & Drop
- HTML Geolocation
- HTML Canvas
- HTML Status Code
- HTML Language Code
- HTML Country Code
- HTML Charset
- MIME Types
HTML kind Attribute
Photo Credit to CodeToFun
🙋 Introduction
The kind
attribute is a feature in HTML used to specify the type of the media resource referenced by the <source> element within an <audio> or <video> tag.
This attribute plays a crucial role in providing information about the nature of the media content, helping browsers to handle and render it appropriately.
🎯 Purpose of kind
The primary purpose of the kind
attribute is to inform the browser about the role of a particular <source> element in relation to the media resource.
This allows the browser to select the most suitable source for rendering based on factors such as codec support and device capabilities.
💎 Values
The kind
attribute accepts several values to describe different types of media content. Some common values include:
- subtitles: Denotes that the media resource is a set of subtitles or captions.
- captions: Specifies that the media resource contains captions.
- descriptions: Indicates that the media resource provides an audio description of the content for users with visual impairments.
- chapters: Represents that the media resource contains chapters or table of contents information.
- metadata: Denotes that the media resource is additional metadata, not intended to be rendered.
📄 Example
Let's look at a basic example of how to use the kind
attribute within a <video> element:
<video controls>
<source src="movie.mp4" type="video/mp4" kind="captions">
<source src="movie.vtt" type="text/vtt" kind="subtitles">
Your browser does not support the video tag.
</video>
🧠 How it Works
In this example, the first <source> element provides captions for the video (kind="captions"), and the second <source> element provides subtitles (kind="subtitles"). The browser uses this information to select the appropriate source for rendering.
🔄 Dynamic Values with JavaScript
Similar to other HTML attributes, you can also dynamically set the kind
attribute using JavaScript.
This is beneficial when you want to change the role of a media resource dynamically based on user interactions or other conditions. Here's a simple example:
<script>
// Dynamically set the kind attribute for a source element
document.getElementById("dynamicSource").kind = "descriptions";
</script>
🧠 How it Works
In this script, the kind
attribute is set to descriptions for a <source> element with the id dynamicSource. This could be useful in scenarios where you want to provide an audio description dynamically based on user preferences.
🏆 Best Practices
- Utilize the
kind
attribute to provide meaningful information about the role of each <source> element within your media elements. - Ensure compatibility by selecting appropriate values based on the content type and user accessibility requirements.
- Test your media elements across different browsers to ensure consistent behavior.
🎉 Conclusion
The kind
attribute is a valuable tool in HTML for specifying the role of media resources within <audio> and <video> elements.
By understanding and leveraging this attribute, you can enhance the accessibility and user experience of your multimedia content.
👨💻 Join our Community:
Author
For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.
Buy me a coffee to make codetofun.com free for everyone.
Buy me a Coffee
If you have any doubts regarding this article (HTML kind Attribute), please comment here. I will help you immediately.