This is a discussion on "<img> element - positioning at center" within the Web Page Design section. This forum, and the thread "<img> element - positioning at center are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
<img> element - positioning at center
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
<img> element - positioning at center
i'm not positive because it's easy to get so many rules confuzed at times, but i think the <align="center"> tag is deprecated in XHTML, correct?
how then would you align an image center? i've tried the following
any ideas on how to get around this? the (x)html looks like this:
, then it might work
thanks! |
|
|
|
#2
|
|||
|
|||
|
First off, don't count on IExplorer. It does not follow the CSS standards. Write using FireFox, then check that it works in IE, not the other way around.
That said...<img> is a replaced element. It does not contain text so text-align in it is useless. Except in IE which doesn't follow the specifications for CSS. To center an image, put the <img> in a block that has text-align:center. <div style="text-align:center"><img src....></div> |
|
#3
|
|||
|
|||
|
What raptor says will work, although I would externalize the style. It makes for cleaner code and better SEO.
Put this in your CSS:
Put this in your CSS:
Be creative, and most importantly make it easy to update!
Last Blog Entry: Whats in a name? (Feb 20th, 2008)
|
|
#4
|
|||
|
|||
|
thanks for the reply! i don't know why i didn't think to just try a div! couldn't see the forest for all those darn trees, i guess.
doesn't {display: block;} cause the replaced element to be treated as a block-level element? Quote:
supposing i were to do as you suggest, and that is to write using Firefox-- what is the idea behind that approach? what would you propose is the benefit? is there some way in which that approach would improve my code, or cross-browser compatibility? |
|
#5
|
|||
|
|||
|
Quote:
i'm not sure i understand the difference here-- other than the obvious which is the use of an ID instead of a class selector. in both cases, you are using the attribute in the <div> tag-- wouldn't they both then apply the {text-align: center;} declaration? i don't claim to be an expert by any means... whch you might have quessed! EDIT: here's the extent of the code on each of the pages which have the image which i want to have centered. i have very many pages nearly identical to this, each of which correponds to a unique item number. in other words, i don't plan to go back and edit all of those html files. i would sooner settle for a left-aligned image for this, a simple pricelist for our vendors which sell our product-- it is not an end-user document, but nonetheless, i'd like to learn what i can while doing it, hence my inquiry here.
|
![]() |
| Tags |
| ltimggt, element, positioning, center |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| an element positioning question | pesho318i | Web Page Design | 5 | Dec 21st, 2007 09:02 |
| help on removing element using yui | shotokan99 | JavaScript Forum | 1 | Aug 31st, 2007 13:42 |
| How To Fix <TD> Element Size? | ivan | Web Page Design | 6 | Dec 11th, 2005 18:43 |
| using params in xsl IF element | zzqproject | Other Programming Languages | 0 | Nov 21st, 2005 23:12 |
| XHTML Block Element in an Inline Element | gohankid77 | Web Page Design | 6 | Jul 27th, 2004 10:15 |