HTML Basic
HTML Reference
- HTML Tags
- HTML Deprecated Tags
- HTML Events
- HTML Attributes
- accept
- accept-charset
- accesskey
- action
- align
- alt
- as
- async
- autocomplete
- autofocus
- autoplay
- bgcolor
- border
- charset
- checked
- cite
- class
- color
- cols
- colspan
- content
- contenteditable
- controls
- coords
- data
- data-*
- datetime
- default
- defer
- dir
- dirname
- disabled
- download
- draggable
- enctype
- enterkeyhint
- for
- form
- formaction
- headers
- height
- hidden
- high
- href
- hreflang
- 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 Global Attributes
- 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.