SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Why this text is on the left side?

    Hello,

    I know this is basic,
    But I can't find the right CSS element that causing this.
    As you can see the text "New York" is on the left side of this page.
    http://hammernailbuilder.com/

    Tell me what CSS making the text "New York" on the left side of the page?
    Thanks in advance.
    Quality codes are optimized and tested...
    Click here for inspiration..

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2013
    Posts
    26
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    it must be taking default alignment

    if you want to align it to center or right, you can just use div tag like this
    Code:
    <div align="center">New York</div>
    or 
    <div align="right">New York</div>

  3. #3
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    @pbsonawane ;

    Thanks dude, but I want to know which CSS element causing it.
    The CSS codes is not from me.
    Quality codes are optimized and tested...
    Click here for inspiration..

  4. #4
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,367
    Mentioned
    180 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    The text is on the left because that is the default setting and there are no other rules in place to change the default.

    If you want to center the text then either place a div around the text and use text-align:center in the css via a class. (Don't use div align="" or the <center> tag as they are deprecated and are code from the last century) . Alerntatively add text-align:center to .content but of course that will affect all text in .content.

  5. #5
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    @Paul O'B ;
    How to center properly not text?

    Thanks in advance.
    Quality codes are optimized and tested...
    Click here for inspiration..

  6. #6
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,367
    Mentioned
    180 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by solidcodes View Post
    @Paul O'B ;
    How to center properly not text?

    Thanks in advance.
    Hi,

    To centre fixed width block elements horizontally you just add margin:auto (specifically left and right margins should be auto). The element needs to have a width defined. If there is no width then the element is 100% wide and effectively there is nothing to centre.

    To centre inline-block elements (or text) just add text-align:centre on a parent div.

    In some cases you may have want width-less containers centred and then you can add display:table and margin:auto to the element and it will be centred in IE8+ (just like a normal table would with margin:auto).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •