Need help with something basic

Discussion in 'HTML & Website Design' started by RH78, Jun 13, 2006.

  1. #1
    Hey guys,

    I'm trying to align a pic by itself on my page and I can't get it to be centered. It's either to the left or the right.

    I'd thought that I could just use <img align="center"> but I quess I'm wrong.

    Anyone have any suggestions (I'm still learning)?


    Thanks.
     
    RH78, Jun 13, 2006 IP
  2. PFCritics

    PFCritics Peon

    Messages:
    107
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Personally, the easiest way IMO is to just wrap the center tags around it.

    <center><img src="http://www.purelywrestling.com/news/wp-content/ecwons2.gif"></center>
    Code (markup):
     
    PFCritics, Jun 13, 2006 IP
  3. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #3
    The center element is no longer a part of html. It should not be used in any new document.

    An image is an inline replaced element. As such, it may be treated as if it were text.
    
    p {
        text-align: center;
        }
    =======
    <p><img src="some.jpg" alt=""></p>
    Code (markup):
    Or you can declare it to display as a block element and center it as you would any other block element.
    
    img {
        display: block;
        margin: 0 auto;
        }
    ===========
    <img src="some.jpg" alt="">
    Code (markup):
    cheers,

    gary
     
    kk5st, Jun 13, 2006 IP
  4. RH78

    RH78 Peon

    Messages:
    158
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks guys. I'm slowly but surely learning this.
     
    RH78, Jun 14, 2006 IP
  5. TechnoGeek

    TechnoGeek Peon

    Messages:
    258
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hello, RH78.
    You can't write <img align="center"> because "align" is not an
    attribute of the "img" tag. Each tag has its set of attributes.
    If you use an erroneous attribute, most probably the browser you are
    using for your tests won't complain, but nothing will happen. Before
    adding an attribute, you should consult your software's help to see
    if the attribute is allowed for the tag. You can also visit my site
    for an introduction to HTML.
     
    TechnoGeek, Jun 16, 2006 IP