1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Don't laugh but, text-align isn't required right?

Discussion in 'HTML & Website Design' started by greenlizard, Dec 28, 2010.

  1. #1
    Okay, this is a very elementary HTML question, but sometimes I over think things. You don't have to set the text alignment correct? If you don't set text-align, then your text will just be the default left to right just like this paragraph that I'm typing right now, correct?

    Again, I feel silly asking this because every site I've ever built I didn't worry about such small details like this. But, I have extra time on my hands today so I'm just wondering... :D

    I guess I'm also just wondering what best practice is regarding this. When you're making a website do you always set the body to text-align: left; or do you not set it at all? With my current website, I didn't set the text-align, but it still looks good in all major browsers so obviously it must not matter. But, again, I'm wondering if there is any reason why you should set the text-align?

    Okay so w3.org points out that by default text-align acts as 'left' if 'direction' is 'ltr', 'right' if 'direction' is 'rtl'. So if a visitor's browser is set to read text ltr then the text alignment on my site will be left, if their device is set to read rtl, then my site's alignment will change to right. I assume. I also assume that most browsers default to left to right, so, to answer my own question... text-align isn't required and my text should always be aligned "left" as long as the user's browser/device is reading from left to right. Or, the only other reason my site's text wouldn't be aligned left would be if I specifically add text-align: right; in my CSS for a particular element, for example.

    Taking this silly topic further then... what if someone wanted to ensure that their site's text was always aligned left... would you then add text-align: left; to the body in your stylesheet?

    Final update:

    So, I decided to just add text-align: left; to the body portion of my stylesheet. Even though left may be the default... I guess it doesn't hurt. This way I know for sure that it's set to left like I want it.
     
    Last edited: Dec 28, 2010
    greenlizard, Dec 28, 2010 IP
  2. ronc0011

    ronc0011 Peon

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yes unless you have it set differently somewhere else further up the chain. These things are hierarchal.
     
    ronc0011, Dec 28, 2010 IP
  3. jeremyhowell

    jeremyhowell Member

    Messages:
    379
    Likes Received:
    7
    Best Answers:
    2
    Trophy Points:
    45
    #3
    You shouldn't have to add text-align left, I only add right or center to the specific elements I want aligned right or center, if nothing on your page is going to have right or centre alignment, theres no need to add the default value again.
     
    jeremyhowell, Dec 28, 2010 IP
  4. radiant_luv

    radiant_luv Peon

    Messages:
    1,327
    Likes Received:
    34
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Congrats, you've got your answer. However, if something is by default, no need to specify it again. You don't want what is by deafult then go for other properties.
     
    radiant_luv, Dec 28, 2010 IP
  5. longcall911

    longcall911 Peon

    Messages:
    1,672
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Why add formatting when none is needed?

    Generally, it adds to code bloat and can cause you heartburn later. I can't count the times I have changed a class only to find that a specific element did not change because someone coded the element when there was no reason to.
     
    longcall911, Dec 29, 2010 IP