Home > Software engineering >  Why is text-align:right not working in this case?
Why is text-align:right not working in this case?

Time:04-10

I am not sure if it's okay to post a site URL but I will try anyway. I am trying to get the phone number at the top of this site (enter image description here

The following simplified code however works

<div  style="text-align:right">
        <a rel="nofollow"  href="tel:0450775238">
            <span >Appelez-nous au 04 50 77 52 38</span>
        </a>
    </div> 

Could anybody please help me understand why it's not working on the site ? and how do I align it to the right ? I don't have access to the HTML of the code and would need to do it using CSS only.

CodePudding user response:

I tested it out. When you change width of parent div to 100% and align it to right. Then this property is working.

Reason: As far as I know, this property depends upon the width of the element on which this is applied to. When you make the width of parent div 100%, which means its width is equal to its parent element which in this case is the whole width of header.

Link element is inline by default.So, if you apply the property to the parent element it will work.

This might be confusing but if you have doubts please let me know.

Have a look at this image

  • Related