Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Centering image

  1. #1
    New to the CF scene
    Join Date
    May 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Centering image

    Hello everybody,

    I am trying to center a simple image but it is not working. I do not know what I am doing wrong. this is my code:

    [html code]
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link rel="stylesheet" type="text/css" href="style.css"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>untitled</title>
    </head>

    <body>
    <img class="center" src="logo.png" width="388" height="239" alt="b&amp;d originals" />
    </body>
    </html>
    [/html code]

    [css code]
    @charset "UTF-8";
    /* CSS Document */
    <style type="text/css">

    .center {
    display: block;
    margin-left: auto;
    margin-right: auto;
    }

    </style>
    [/css code]

    link to the website for preview and to see what it is doing with the above code:
    http://img19.imageshack.us/img19/3670/screenshot20130521at855.png

    and no I'm not messing around, just didn't want to put a real logo on here...

    Could somebody tell me what I am doing wrong??? Why is the image not centering???

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,300
    Thanks
    28
    Thanked 275 Times in 269 Posts
    Quote Originally Posted by bkoo View Post
    Could somebody tell me what I am doing wrong??? Why is the image not centering???
    Your CSS style sheet contains HTML code. Remove that code to resolve your issue.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #3
    New to the CF scene
    Join Date
    May 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you mean the charset=UTF-8" part? in the css?

    I tried that it doesn't work.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    When using an external CSS file, there shouldn't be the html <style> </style> tags inside it.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New to the CF scene
    Join Date
    May 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Resolved

    Thank you!!!!!!!!!!!!!

  • #6
    New Coder
    Join Date
    Jan 2013
    Posts
    71
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Use CSS without using HTML code into it.


  •  

    Tags for this Thread

    Posting Permissions

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