Amr Elnashar
Amr Elnashar

Reputation: 1769

css style Centering in safari

i'm using css style like this

text-align:center;

its working in IE and doesn't work with Safari..

any suggestions.

thanks,

Upvotes: 0

Views: 428

Answers (4)

Amr Elnashar
Amr Elnashar

Reputation: 1769

I got the point I made that code:

width: 190px;
padding-left:23px;
height: auto;
text-align: left;
line-height: 18px;

and its working right now thanks for all trying to help me

Upvotes: 0

Dave Markle
Dave Markle

Reputation: 97771

It depends on what you are trying to style. You are probably trying to center a block level element like a DIV or UL. In that case, you center using

div {
    margin-left:auto;
    margin-right:auto;
    padding-left:<some fixed size>;
    padding-right:<some fixed size>;
    width:<some fixed size>;
}

Upvotes: 2

BalusC
BalusC

Reputation: 1109262

Centering textual content has as far as I know no specific browser/doctype issues. So it look like that you're trying to center something else than text. If you actually want to center a block element, give it a fixed width (in pixels) and apply margin: 0 auto; on it as well.

Here's an SSCCE

<!doctype html>
<html lang="en">
    <head>
        <title>SO question 1897444</title>
        <style>
            #center {
                margin: 0 auto; /* top and bottom 0, left and right expanding. */
                width: 300px; /* Required to have a reference point to center. */
                border: 1px solid black; /* Not required, just presentational. */
            }
        </style>
    </head>
    <body>
        <div id="center">Centered block element</div>
    </body>
</html>

This however won't work in IE in quirks mode. Just ensure that you're using a strict doctype.

Upvotes: 4

daotoad
daotoad

Reputation: 27193

Validating your html and css is the first step to figuring out any rendering issues (even in craptastic browsers like IE 6).

Upvotes: 1

Related Questions