General Community > HTML/CSS
centering ellements using css?
Tim:
Does anybody know a way to center a block using just css?
so far the only thing I've found was
--- Code: ---.block{
width: 90%;
margin-left: 5%;
margin-right: 5^%;
}
--- End code ---
but that results in some browser issues...
Joel:
Margin: auto will center a block element as long as the width is set.
--- Code: ---.block { width: 90%; margin: auto; }
--- End code ---
Tim:
have you got a working example, because I can't get it to work :-/
Joel:
Do you have a valid DOCTYPE? If not, the browser will default to tag soup mode (for old and non-standards compliant pages). It also keeps margin: auto from working.
http://www.w3schools.com/tags/tag_doctype.asp
Tim:
yah, I know how to do valid html ;)
they should really put an align statement in css :-\
Navigation
[0] Message Index
[#] Next page
Go to full version