To fix this.. you have to add text-align:center; to the parent element
of the IMG.
e.g if the image was inside a DIV
<div id="content">
<img src="fred.gif" width="200" height="100" alt="This is Fred."
id="imgFred" />
</div>
the CSS would be
div#content
{ width:400px;
text-align:center;
}
Then the image would be centered.
If this still fails, try adding this CSS.
img#imgFred
{ margin-left:auto;
margin-right:auto;
}
If you have an example page, we could help more.
Dave
--
Little Dave
http://www.daveholloway.co.uk
Everyone feel free to add me to your instant messengers:
MSN: daveho...@spamcop.net, YAHOO: daveho...@yahoo.com, ICQ: 104452444
> Daniel wrote:
>> I need help with aligning an image in CSS1. I can't seem to center
>> the image without using the depreciated attribute in the image tag.
>> I've tried to use float, but no avail. I am using IE, if that helps.
>> Thanks in advance.
>
> To fix this.. you have to add text-align:center; to the parent element
> of the IMG.
>
> e.g if the image was inside a DIV
>
> <div id="content">
> <img src="fred.gif" width="200" height="100" alt="This is Fred."
> id="imgFred" />
> </div>
>
> the CSS would be
>
> div#content
> { width:400px;
> text-align:center;
> }
>
> Then the image would be centered.
>
> If this still fails, try adding this CSS.
>
> img#imgFred
> { margin-left:auto;
> margin-right:auto;
> }
>
> If you have an example page, we could help more.
>
> Dave
>
Thanks, it worked well. I was using the class ID and the .class in the
style tags, but they didn't work with the text-align. Why does id make the
difference???
> Thanks, it worked well. I was using the class ID and the .class in the
> style tags, but they didn't work with the text-align. Why does id make the
> difference???
I haven't a clue. If you can send some sample code/upload an example
page, I should be able to tell you.
It is probably something to do with specifity.. which is a real
noodle-scratcher as there are so many things to remember.
> Daniel spake:
>
>> Thanks, it worked well. I was using the class ID and the .class in
>> the style tags, but they didn't work with the text-align. Why does
>> id make the difference???
>
> I haven't a clue. If you can send some sample code/upload an example
> page, I should be able to tell you.
> It is probably something to do with specifity.. which is a real
> noodle-scratcher as there are so many things to remember.
>
> Dave
>
>
The page I am using all of this on is www.contagiousrock.com
> The page I am using all of this on is www.contagiousrock.com
Okay, I still haven't a clue.
But on a completely unrelated matter: I have a suggestion:
Add this script to your page (its very useful):
<script type="text/javascript">
function deOcities()
{ yfiOC(-1); }
window.onload=deOcities;
</script>
Regards
> Cankersore wrote:
>
>> The page I am using all of this on is www.contagiousrock.com
>
> Okay, I still haven't a clue.
>
> But on a completely unrelated matter: I have a suggestion:
> Add this script to your page (its very useful):
>
> <script type="text/javascript">
> function deOcities()
> { yfiOC(-1); }
> window.onload=deOcities;
> </script>
>
> Regards
>
> Dave
>
Sorry bout the name change on you. Two different computers, work and
personal. www.contagiousrock.com is the website I am using all of this on.
I have most of my css in a single stylesheet, but I only needed to center
the website image at the very top, and the band picture underneath it
(ghastly pic, isn't it?)
BTW, what does that script do?
> BTW, what does that script do?
Its a surprise. Don't worry, it doesn't do anything malicious. It will
remove something "adverty" from the page.
Dave
ps. yes. ghastly pic.