- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <bdi> Tag
HTML <bdi> tag stands for Bidirectional Isolate Element. It differentiates a text from other texts that may be formatted in a different direction. Generally, it is useful when a website dynamically inserts some text and doesn’t know the text's directionality. A text that can contain both left-to-right (LTR) and right-to-left (RTL) character sequences is referred to as bidirectional text.
For example, Latin characters are treated as LTR while Arabic characters are treated as RTL. To know about LTR and RTL check CSS - Direction.
HTML <bdi> tag works in two ways:- The directionality of the embedded text in <bdi> has no effect on the directionality of the surrounding text.
- The directionality of embedded text in <bdi> is unaffected by the directionality of the surrounding text.
Syntax
<bdi>...</bdi>
Attribute
HTML bdi tag supports Global and Event attributes of HTML.
Examples of HTML bdi Tag
In these exanples we will witness multiple examples of HTML bdi tag, where each example was defining the characteristics of bdi tag.
Independently embedding Context
In the following example, let’s see the usage of <bdi> tag with LTR and RTL text. We get the winner of the competition using the <bdi> tag. These components instruct the browser to treat the name independently of its embedding context, so the example output is properly ordered.
<!DOCTYPE html> <html> <body> <ul> <li> <bdi class="name">اَلأَعْشَى</bdi> - 1st place </li> <li> <bdi class="name">Jerry Cruncher</bdi> - 2nd place </li> </ul> </body> </html>
Bidirectional algorithm with bdi Element
Here we are creating an HTML document and using the <bdi> tag to display the username with their points. If the browser does not support the bdi tag, the Arabic user's username will confuse the text (the bidirectional algorithm will place the colon and the number "90" next to the word "user" rather than next to the word "points").
<!DOCTYPE html> <html> <body> <h1>The bdi element</h1> <ul> <li>User <bdi>hrefs</bdi>: 60 points </li> <li>User <bdi>jdoe</bdi>: 80 points </li> <li>User <bdi>إيان</bdi>: 90 points </li> </ul> </body> </html>
Styling bdi Element
In the following example, we’re creating an HTML document and using the <bdi> tag and the CSS properties to style the content of the bdi tag.
<!DOCTYPE html> <html> <head> <style> bdi{ color: red; font-style: italic; } </style> </head> <body> <h1>The bdi element</h1> <ul> <li>User <bdi>hrefs</bdi>: 60 points </li> <li>User <bdi>jdoe</bdi>: 80 points </li> <li>User <bdi>إيان</bdi>: 90 points </li> </ul> </body> </html>
Supported Browsers
Tag | |||||
---|---|---|---|---|---|
bdi | Yes 16.0 | Yes 79.0 | Yes 10.0 | Not Supported | Yes 15.0 |
To Continue Learning Please Login
Login with Google