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 standby Attribute
Photo Credit to CodeToFun
🙋 Introduction
The standby
attribute is an attribute used in HTML with the <object> element. Although it is not widely used or supported in modern browsers, it was originally intended to provide a message that would be displayed while the object is loading.
Understanding deprecated or less common attributes like standby can be useful for maintaining legacy code or understanding the evolution of web standards.
🎯 Purpose of standby
The standby
attribute was designed to enhance user experience by displaying a message while an embedded object (such as an image, video, or other media) is loading. This could inform users that content is being loaded and improve the perceived performance of a web page.
💎 Values
The standby
attribute accepts a string value, which is the text message to be displayed while the object is loading. Here is a basic example:
<object data="example.swf" type="application/x-shockwave-flash" standby="Loading, please wait...">
<p>Your browser does not support embedded objects.</p>
</object>
🧠 How it Works
In this example, the message "Loading, please wait..." would be shown to users while the Flash object is being loaded.
📄 Implementation Example:
Since the standby
attribute is not widely supported, it is often better to use other methods, such as JavaScript, to achieve similar functionality. However, here is how it would be used in an HTML document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Standby Attribute Example</title>
</head>
<body>
<object data="example-video.mp4" type="video/mp4" standby="Video is loading...">
<p>Your browser does not support embedded videos.</p>
</object>
</body>
</html>
🔄 Dynamic Values with JavaScript
To achieve a similar effect dynamically with JavaScript, you can manipulate the DOM to display a loading message while content is being fetched or loaded. Here's an example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dynamic Standby Example</title>
<style>
#loadingMessage {
display: none;
font-size: 1.2em;
color: #555;
}
</style>
</head>
<body>
<div id="loadingMessage">Loading content, please wait...</div>
<object id="dynamicObject" data="" type="video/mp4">
<p>Your browser does not support embedded videos.</p>
</object>
<script>
document.addEventListener("DOMContentLoaded", function() {
var loadingMessage = document.getElementById("loadingMessage");
var dynamicObject = document.getElementById("dynamicObject");
loadingMessage.style.display = "block";
dynamicObject.data = "example-video.mp4";
dynamicObject.onload = function() {
loadingMessage.style.display = "none";
};
});
</script>
</body>
</html>
🧠 How it Works
In this script, a loading message is displayed when the page loads and is hidden once the object has finished loading.
🏆 Best Practices
- Given that the
standby
attribute is deprecated and not widely supported, it is advisable to use JavaScript or CSS for displaying loading messages. - Always test your solutions across different browsers to ensure compatibility and a smooth user experience.
- Use semantic HTML and ARIA roles to ensure accessibility when providing dynamic loading messages.
🎉 Conclusion
The standby
attribute, while not commonly used today, was designed to enhance the user experience by displaying a message while content is loading. In modern web development, similar functionality can be achieved using JavaScript and CSS, providing more control and better compatibility across browsers.
Understanding attributes like standby helps in maintaining legacy code and appreciating the evolution of HTML standards.
👨💻 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 standby Attribute), please comment here. I will help you immediately.