| | |
div align="center"
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2008
Posts: 101
Reputation:
Solved Threads: 9
The above HTML code is sometimes ignored by FireFox, but worse: It's not even allowed in XHTML1.0 Strict.
I have updated my sites to be "Strict" compatible, except for this little thing which is important enough. The problem is that I have found nothing to replace it.
In this example:
the image should be centered, but even if I enclose it by a div with text-align:center,
FireFox places the image to the far left. This happens with many other objects as well, especially if they are defined as block elements.
Surely it shouldn't be like this?
Or rather, how can we continue having centered objects while confirming to the newer standards?
I could write a table-like construct using divs and css, but that would be extremely clumsy for a little thing like this. I'm looking for a simple solution, where HTML defines the content and css the style!
I have updated my sites to be "Strict" compatible, except for this little thing which is important enough. The problem is that I have found nothing to replace it.
In this example:
HTML and CSS Syntax (Toggle Plain Text)
<a href="http://greatday.com/motivate/index.html"> <img style="width:18em;" src="http://greatday.com/motivate/dmsum.gif" alt="Daily Motivator" title="Daily Motivator" /></a>
the image should be centered, but even if I enclose it by a div with text-align:center,
FireFox places the image to the far left. This happens with many other objects as well, especially if they are defined as block elements.
Surely it shouldn't be like this?
Or rather, how can we continue having centered objects while confirming to the newer standards?
I could write a table-like construct using divs and css, but that would be extremely clumsy for a little thing like this. I'm looking for a simple solution, where HTML defines the content and css the style!
Here is an interesting statistic:
Yahoo has hundreds of HTML/CSS errors that don't comply with standards.
No website is absolutely prefect when it comes to standards. (Not like I'm volunteering to check!!!). I would suggest simply using a less-strict standard. I usually code in XHTML 1.0 Transitional.
Yahoo has hundreds of HTML/CSS errors that don't comply with standards.
No website is absolutely prefect when it comes to standards. (Not like I'm volunteering to check!!!). I would suggest simply using a less-strict standard. I usually code in XHTML 1.0 Transitional.
To center a block-type object, within another block type object, use this code on the object that you want to be centered ( i.e. on the inner object ):
although, tbh,
anyway, for best compatibility, use
HTML and CSS Syntax (Toggle Plain Text)
style="margin-left:auto;margin-right:auto;"
text-align:center; really should work, since an image isn't supposed to be a block-type object. anyway, for best compatibility, use
text-align:center; on the outer object, and margin-left:auto;margin-right:auto; on the image. Last edited by MattEvans; Oct 12th, 2008 at 11:14 pm.
Plato forgot the nullahedron..
•
•
Join Date: Jul 2008
Posts: 101
Reputation:
Solved Threads: 9
•
•
•
•
To center a block-type object, within another block type object, use this code on the object that you want to be centered ( i.e. on the inner object ):
although, tbh,HTML and CSS Syntax (Toggle Plain Text)
style="margin-left:auto;margin-right:auto;"text-align:center;really should work, since an image isn't supposed to be a block-type object.
anyway, for best compatibility, usetext-align:center;on the outer object, andmargin-left:auto;margin-right:auto;on the image.
Thank you very much!
•
•
Join Date: Sep 2008
Posts: 29
Reputation:
Solved Threads: 2
always use
margin-left:auto;
margin-right:auto;
because if u use this code rather then your one then if in any case if browser screen size is change due to any reason then the left and right margin are auto set for equal value according to the size of screen and this one is a better idea or one of the best
and one importent thing is that you should use external css rather then this internal one
-PC(INDIA)
margin-left:auto;
margin-right:auto;
because if u use this code rather then your one then if in any case if browser screen size is change due to any reason then the left and right margin are auto set for equal value according to the size of screen and this one is a better idea or one of the best
and one importent thing is that you should use external css rather then this internal one
-PC(INDIA)
•
•
Join Date: Oct 2008
Posts: 89
Reputation:
Solved Threads: 4
ok let me make it easier to u in all browsers. jsut use this style in the div . this margin 0 auto is for firefox and flock, while the text align will work in browsers like ie opera etc
cheers
•
•
•
•
style="margin:0 auto; text-align:center;"
cheers ![]() |
Similar Threads
- PHP Mysql "Where" statement (PHP)
- Page "bleed" off edge (HTML and CSS)
- "Use of uninitialized value in substitution (s///) at (eval 44) line 44. [Thu Apr 19 (Perl)
- Selectively Printing only Certain Divs (javascript/css question) (JavaScript / DHTML / AJAX)
- Content Breaking thru Borders (JavaScript / DHTML / AJAX)
- <script language=\"javascript\"> Display problem with PHP & MYSQL (PHP)
- Have a problem with centering "jpg" files (HTML and CSS)
- document.write to new window and into a 3 column table! Help Please! (JavaScript / DHTML / AJAX)
- Problems with html code (HTML and CSS)
Other Threads in the HTML and CSS Forum
- Previous Thread: css problem
- Next Thread: IE7 Png trensparency problem.
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7






