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 scheme Attribute
Photo Credit to CodeToFun
🙋 Introduction
The scheme
attribute in HTML is used to specify the Internet scheme (protocol) that an input field's value should adhere to. This attribute was more commonly used in earlier versions of HTML but has since been deprecated in HTML5.
However, understanding its usage can be beneficial for maintaining and understanding legacy HTML documents.
🎯 Purpose of scheme
The primary purpose of the scheme
attribute was to provide hints about the protocol for the data being entered into the input field. It helped to inform the user agent (browser) about the expected format of the data, such as "http", "https", "ftp", etc.
💎 Values
The scheme
attribute could accept various protocol values depending on the expected data format. Some common values included:
- http: Indicates that the input should follow the HTTP protocol.
- https: Indicates that the input should follow the HTTPS protocol.
- ftp: Indicates that the input should follow the FTP protocol.
- mailto: Indicates that the input should follow the mailto scheme for email addresses.
- tel: Indicates that the input should follow the telephone scheme for phone numbers.
Although the scheme
attribute is deprecated, understanding its historical usage can still be valuable when working with older HTML documents.
📄 Implementation Example:
Here’s an example of how the scheme
attribute might have been used in an HTML form:
<form>
<label for="url">Website URL:</label>
<input type="text" id="url" name="url" scheme="https">
<label for="email">Email:</label>
<input type="email" id="email" name="email" scheme="mailto">
<input type="submit" value="Submit">
</form>
🧠 How it Works
In this example, the scheme
attribute specifies that the URL should follow the HTTPS protocol and the email should follow the mailto scheme.
🔄 Dynamic Values with JavaScript
Even though the scheme
attribute is deprecated, understanding how to manipulate attributes dynamically with JavaScript remains a useful skill. Here’s how you could dynamically set an attribute using JavaScript:
<script>
// Dynamically set the scheme attribute for an input field
document.getElementById("dynamicField").setAttribute("scheme", "ftp");
</script>
🧠 How it Works
In this script, the scheme
attribute is dynamically set to "ftp" for an input field with the id "dynamicField". This demonstrates how attributes can be managed using JavaScript.
🏆 Best Practices
- Since the
scheme
attribute is deprecated in HTML5, it’s recommended to use other methods to achieve similar functionality, such as pattern attributes and client-side validation scripts. - When dealing with legacy code, understanding the
scheme
attribute can help in maintaining and upgrading older HTML documents. - Always ensure that your forms and input fields are secure, especially when dealing with protocols and sensitive data.
🎉 Conclusion
While the scheme
attribute is no longer a part of modern HTML standards, it played a role in guiding data input formats in older HTML versions.
Understanding its purpose and usage can be helpful for those maintaining legacy systems or learning about the evolution of web technologies.
👨💻 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 scheme Attribute), please comment here. I will help you immediately.