Template:Bdo
{{{1}}}
Usage
{{bdo}} is a front-end for the HTML element <bdo>
, which is used to delimit a span of text that has a text direction which is known and opposite to that of the main text. It enables the use of, e.g. Arabic script as inline text in an English article (and vice versa).
Mixed text directions often causes text flow problems. Words will become jumbled at line-breaks, and punctuation marks may be displayed on the wrong side of the string, since they get interpreted as part of the inserted text.
By default, this template will set the value for the text direction to dir="rtl"
, forcing any text entered into it to flow from right to left.
Parameters
There are 2 parameters, of which is unnamed and required, and the other is named and optional.
Syntax
The template's syntax is
-
{{bdo|custom text |dir=ltr }}
Required parameter
1
- Custom text
The text that should be enclosed in <bdo>
tags.
- Usage
-
{{bdo|1}}
Optional parameter
dir
- Changes the text direction (to ltr)
This parameter should only be used to change the text direction within the tag pair from the default right-to-left (rtl) to left-to-right (ltr).
- Usage
-
{{bdo|1|dir=ltr}}
Available value
Affected attribute |
Value | Description | Default value |
---|---|---|---|
dir |
ltr | Changes the default text direction of the template | rtl |
Examples
Correct use
Case | What you type | What you see |
---|---|---|
Basic use | موزيلا فيرفكس}} | موزيلا فيرفكس |
In inline text | موزيلا فيرفكس}}, is a popular web-browser. | Mozilla Firefox, in Arabic موزيلا فيرفكس, is a popular web-browser. |
Changing to ltr | dir}} parameter is correctly set, the text runs {{bdo|dir=ltr|from left to right}} , if incorrectly specified it's {{bdo|the other way around}} . |
When the dir parameter is correctly set, the text runs from left to right, if incorrectly specified it's the other way around.
|
Comparison between <bdi> and <bdo>
The <bdi>
tag derives the direction of the text it encloses from the text itself. You don't include any directional information. The <bdo>
tag, however, forces the text it encloses to flow in a certain direction, specified through the attribute dir=
.
Because of that, {{bdo}} shouldn't be used in cases where the direction of the inserted text is unknown, but it is a good alternative if {{bdi}} should fail to derive the direction.
<bdi>
The <bdi>
tag is used in the same way, regardless of the text direction of the inserted string.
Case | What you type | What you see | Comments |
---|---|---|---|
<bdi> adapts to the text direction of the enclosed string |
من اليمين إلى اليسار}} | من اليمين إلى اليسار | Works for both rtl and ltr input |
From left to right}} | From left to right |
<bdo>
The <bdo>
tag may make the text virtually unreadable, if used incorrectly. Mind the dir=
.
- Correct
Case | What you type | What you see | Comments |
---|---|---|---|
<bdo> has a preset directional output |
من اليمين إلى اليسار}} | من اليمين إلى اليسار | The default direction is rtl |
dir=ltr|From left to right}} | From left to right | ltr must be explicitly specified |
- Incorrect
Case | What you type | What you see | Comments |
---|---|---|---|
Wrong value for the dir attribute |
dir=ltr|من اليمين إلى اليسار}} | من اليمين إلى اليسار | The text is displayed backwards (<bdo> forces the direction)
|
From left to right}} | From left to right |
See also
- {{bdi}}: inserts
<bdi>
tags to allow for inline changes in text direction.
The above documentation is transcluded from Template:Bdo/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |