lang and dir attribute of HTML em element
lang and dir attributes of HTML em element specifiy the language and text direction respectively of an em element.
HTML em element lang attribute
1. lang attribute of HTML em element sets the language of the element in HTML document. Like other HTML elements, here also, usage of lang attribute helps the browser to display the text to be displayed in the desired language.
2. The value of the lang attribute is the language code specified by the W3C to be used with HTML.
Syntax
<em lang="language_code" >text content</em>
Example of using lang attribute with HTML em element
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML em tag example lang attribute - HTML tutorial | w3resource</title>
</head>
<body>
<p>This following text is in french : <em lang="fr">Ce paragraphe est en français.</em></p>
</body>
</html>
Result
View this example in a separate browser window
Example lang attribute of em tag
Description HTML em element dir attribute
1. dir attribute of HTML em element sets the direction of the text within an em element in HTML document.
2. The value of the dir attribute is either ltr (i.e. left to right) or rtl (i.e. right to left).
Example of using dir attribute with HTML em element
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML em tag example dir attribute - HTML tutorial | w3resource</title>
</head>
<body>
<p>Following text is in left to right direction : <em dir="ltr">left to right text.</em></p>
<p>Following text is in right to left direction : <em dir="rtl">מימין לשמאל הטקסט</em>
</body>
</html>
Result
View this example in a separate browser window
Example dir attribute of em tag
Note
If you are using a plain text editor like notepad to write right to left text using dir="rtl", you must set the encoding style to UNICODE while saving the file.
Previous: id and class attribute of HTML em element
Next: HTML em tag title attribute
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/html/em/HTML-em-tag-language-information-and-text-direction-attributes.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics