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 frameborder Attribute
Photo Credit to CodeToFun
🙋 Introduction
The frameborder
attribute is used in HTML to control whether or not to display a border around frames.
Frames are a deprecated feature in HTML, but understanding the frameborder
attribute can still be relevant for maintaining older web pages or dealing with legacy code.
🎯 Purpose of frameborder Attribute
The frameborder
attribute determines whether a visible border should be drawn around frames within a frameset. This attribute is typically applied to the <frame> or <iframe> elements in HTML.
💎 Values
The frameborder
attribute accepts two main values:
- 1: This is the default value. It indicates that a border should be drawn around the frame.
- 0: This value indicates that no border should be drawn around the frame.
📄 Implementation Example:
Here's a basic example demonstrating the use of the frameborder
attribute within an <iframe> element:
<iframe src="example.html" frameborder="1"></iframe>
🧠 How it Works
In this example, the frameborder
attribute is set to "1", indicating that a border should be displayed around the iframe.
🔄 Dynamic Values with JavaScript
While the frameborder
attribute is typically set statically in HTML, you can also manipulate it dynamically using JavaScript. For instance, you might want to change the frameborder value based on user interactions or certain conditions in your web application.
<iframe id="dynamicFrame" src="example.html"></iframe>
<script>
// Dynamically set the frameborder attribute
var frame = document.getElementById("dynamicFrame");
frame.frameborder = 0; // Set the frameborder attribute to 0
</script>
🧠 How it Works
In this script, the frameborder
attribute of the iframe with the id "dynamicFrame" is set to "0" dynamically using JavaScript.
🏆 Best Practices
- When using frames or iframes, it's important to consider their impact on usability, accessibility, and search engine optimization (SEO). In modern web development, alternatives such as CSS for layout and AJAX for dynamic content loading are often preferred over frames.
- If you must use frames or iframes, be mindful of the
frameborder
attribute and its effect on the visual appearance of your frames.
🎉 Conclusion
Although frames are considered deprecated in modern web development, the frameborder
attribute remains relevant for controlling the display of borders around frames.
Understanding how to use this attribute can be helpful when working with legacy code or maintaining older websites.
👨💻 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 frameborder Attribute), please comment here. I will help you immediately.