
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- 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
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to represent text that must be isolated from its surrounding for bidirectional text formatting in HTML?
The <bdi> HTML element instructs the bidirectional algorithm of the browser to treat the text it contains independently of the content around it. It's very helpful when a website dynamically adds some text without knowing which direction it should go.
For example, few languages like Arabic, Urdu or Hebrew are written in the right – to – left direction instead of the usual left – to – right. We use the <bdi></bdi> tag before and after the text that goes in the opposite direction of the script to rearrange it.
However, if there is confusion about the text direction or we do not know which direction the text goes in, apply the dir = auto tag to any markup wrapping the text location. But if there is no markup present, wrap the text with the bdi tag again.
Syntax
<bdi> text </bdi>
Following are the examples…
Example
In the following example we are using bdi element to represent a span of text to get isolated from its surroundings. Here, we are wrapping one line in Arabic using the bdi tag and another line with the span markup using the dir = auto tag.
<!DOCTYPE html> <html> <body> <h1>World wrestling championships</h1> <ul> <li><bdi class="name">Akshay</bdi>: 1st place</li> <li><bdi class="name">Balu</bdi>: 2nd place</li> <li><span class="name">Mani</span>: 3rd place</li> <li><bdi class="name">الرجل القوي إيان</bdi>: 4th place</li> <li><span class="name" dir="auto">تیز سمی</span>: 5th place</li> </ul> </body> </html>
Output
On executing the above script, the output window opens up consisting of different wrestling champions added with <bdi> along with their position to make our text in the right way.
- Related Articles
- HTML Text Formatting
- Formatting Text in CSS
- How to set that the text direction will be submitted in HTML?
- Formatting Text Using CSS
- How to add a spellchecker for text in HTML?
- How to center text in HTML?
- How to handle the error “Text strings must be rendered within a component” in ReactNative?
- How to change text font for JLabel with HTML in Java?
- How to Create a Multi-line Text Input (Text Area) In HTML?
- How to add preformatted text in HTML?
- How to create teletype text in HTML?
- How to display deleted text in HTML?
- How to set Text alignment in HTML?
- How to make text bold in HTML?
- How to make text italic in HTML?
