Jump to content
leela52452

why do we need dir Attribute if lang="en"

Recommended Posts

It's optional, I don't see a reason to use it.

  • Thanks 1

Share this post


Link to post
Share on other sites

Hello @leela52452,
dir attribute is used to set the direction of the text within an element in an HTML document.
If you set it as an RTL then it will display HTML from right to left. It generally used when language is like Arabic etc.
dir attribute is not a compulsory attribute so you can also skip this.

  • Thanks 1

Share this post


Link to post
Share on other sites

dir attribute sets the direction of the text within an element in HTML document,it is not complusory, the value of the dir attribute is either ltr (i.e. left to right) or rtl (i.e. right to left).

Share this post


Link to post
Share on other sites

Hello, we use dir tag to apply direction to our text for example :

 

Add dir="rtl" to the html  tag any time the overall document direction is right-to-left. This sets the base direction for the whole document.

No dir attribute is needed for documents that have a base direction of left-to-right, since this is the default.

 

<!DOCTYPE html>
<html dir="rtl" lang="ar">
<head>
<meta charset="utf-8">
...

Adding dir="rtl" to the html element will cause block elements and table columns to start on the right and flow from right to left. All block elements in the document will inherit this setting unless the direction is explicitly overridden.

Same goes for ltr(Left to right ) {rtl(Right to Left)}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...