Jump to content

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


leela52452

Recommended Posts

  • 4 weeks later...

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
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

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)}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...