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 version Attribute
Photo Credit to CodeToFun
🙋 Introduction
The version
attribute in HTML is used to specify the version of the HTML standard that a document adheres to. Although it was used in early versions of HTML, it is now considered obsolete and is not supported in HTML5.
Understanding the historical context and use of this attribute can provide insight into the evolution of HTML standards.
🎯 Purpose of version
In early HTML specifications, the version
attribute was used to declare the version of HTML a document was written in. This helped browsers to render the content correctly according to the specified standard. However, as HTML evolved, this attribute was phased out in favor of other methods, such as the <!DOCTYPE> declaration, which serves a similar purpose in modern HTML.
💎 Values
The version
attribute could take specific values corresponding to different versions of HTML. Here are some examples of the values that were used:
- HTML 2.0: version="2.0"
- HTML 3.2: version="3.2"
- HTML 4.01: version="4.01"
📄 Implementation Example:
Although the version
attribute is obsolete, here is an example of its usage in an older HTML document:
<html version="4.01">
<head>
<title>Example with version attribute</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is an example of an HTML document with the version attribute.</p>
</body>
</html>
🧠 How it Works
In this example, the version
attribute is set to "4.01", indicating that the document adheres to HTML 4.01 standards.
🔄 Dynamic Values with JavaScript
While the version
attribute is obsolete and not applicable in modern HTML, it is still possible to manipulate attributes dynamically using JavaScript for educational or experimental purposes. Here’s how you could set an attribute dynamically:
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Version Attribute Example</title>
<script>
// Dynamically set the version attribute (for demonstration purposes only)
document.addEventListener("DOMContentLoaded", function() {
document.documentElement.setAttribute("version", "4.01");
});
</script>
</head>
<body>
<h1>Hello, World!</h1>
<p>This demonstrates setting a version attribute dynamically with JavaScript.</p>
</body>
</html>
🧠 How it Works
In this script, the version
attribute is set dynamically for the html element when the document content is loaded. This is purely for demonstration, as modern HTML does not utilize this attribute.
🏆 Best Practices
- Avoid using obsolete attributes like version in modern web development.
- Use the <!DOCTYPE> declaration to specify the HTML version for modern documents. For example, use <!DOCTYPE html> for HTML5.
- Keep your HTML code up-to-date with current standards to ensure compatibility and proper rendering across all browsers.
🎉 Conclusion
The version
attribute in HTML was historically used to declare the version of HTML a document adhered to, but it is now obsolete.
Understanding its purpose and usage helps appreciate the evolution of HTML standards. In modern web development, always use the <!DOCTYPE> declaration to specify the HTML version.
👨💻 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 version Attribute), please comment here. I will help you immediately.