473,804 Members | 3,894 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Centering an image with css

I think this is an easy one, but I have not been able to find it anywhere.

In HTML, I used <center><img src="whatever.g if></center> to horizontally
center a graphic on a page. What is the CSS way of doing the same?

Thanks, Carolyn

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Aug 31 '05 #1
10 8509
Carolyn Marenger <ca****@marenge r.com> wrote:
In HTML, I used <center><img src="whatever.g if></center> to horizontally
center a graphic on a page. What is the CSS way of doing the same?


p{text-align:center}

<p><img src="image.png" alt="alt content here"></p>

--
Spartanicus
Aug 31 '05 #2
Spartanicus wrote:
Carolyn Marenger <ca****@marenge r.com> wrote:
In HTML, I used <center><img src="whatever.g if></center> to horizontally
center a graphic on a page. What is the CSS way of doing the same?


p{text-align:center}

<p><img src="image.png" alt="alt content here"></p>


Thanks!

Carolyn

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Aug 31 '05 #3
Carolyn Marenger:
I think this is an easy one,
It is.
but I have not been able to find it anywhere.


That's actually hard to believe, how did you search?
Aug 31 '05 #4
Christoph Päper wrote:
Carolyn Marenger:
I think this is an easy one,


It is.
but I have not been able to find it anywhere.


That's actually hard to believe, how did you search?


Yeah, I know. I found it within a good 30 seconds after I asked here.

Thanks anyway. Carolyn

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Aug 31 '05 #5
In transitional, I just say align="right", and the image lines up on
the right hand side, and the text flows around the image.

I can easily put the image on the right hand side in strict for
example telling it to float right, but the text does not flow around
the image.
--
http://www.jim.com
Sep 1 '05 #6
James A. Donald <ja****@echeque .com> wrote:

Who and what are you responding to?

There is a posting convention in this group: configure your software to
inject an attribution line on top, snip what you are directly responding
to to a minimum, and put your reply beneath it, thus creating an
interspersed message (like this).
In transitional
No-one should be authoring new documents using transitional anymore.
, I just say align="right", and the image lines up on
the right hand side, and the text flows around the image.
[Browsing up the thread]

What on earth does this have to do with the OPs query?
I can easily put the image on the right hand side in strict for
example telling it to float right, but the text does not flow around
the image.


Then you've made a mistake somewhere.

--
Spartanicus
Sep 1 '05 #7
James A. Donald:
I can easily put the image on the right hand side in strict for
example telling it to float right, but the text does not flow around
the image.

On Thu, 01 Sep 2005 06:54:12 GMT, Spartanicus Then you've made a mistake somewhere.


example:

The following works, but is not strict because of the image has the
attribute align=right (among other things)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test</title>
</head>

<body>
<h1>Test</h1>
<p><a href="http://www.jim.com/tolerati.htm">L etter
concerning toleration. </a><a
href="http://www.jim.com/tolerati.htm">< img
src="locket.jpg " alt="Locke" align="right"
height="85" width="75"></a>
<P>John Locke argues
that religious persecution is not caused
by differing concepts of the good, but by simple
old fashioned evil - one group seeks power and wealth by using
organized violence to rob and subjugate another group,
same as any other group conflict.
</body>
</html>

The following does not work at all (style="text-align: right;"),
perhaps because an image is not text.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test</title>
</head>

<body>
<h1>Test</h1>
<p><a href="http://www.jim.com/tolerati.htm">L etter
concerning toleration. </a><a
href="http://www.jim.com/tolerati.htm">< img
src="locket.jpg " alt="Locke" style="text-align: right;"
height="85" width="75"></a>
<P>John Locke argues
that religious persecution is not caused
by differing concepts of the good, but by simple
old fashioned evil - one group seeks power and wealth by using
organized violence to rob and subjugate another group,
same as any other group conflict.
</body>
</html>

I would like it to look like the transitional does - where the text
flows around the right aligned image.

--
http://www.jim.com
Sep 1 '05 #8
Els
James A. Donald wrote:
James A. Donald:
I can easily put the image on the right hand side in strict for
example telling it to float right, but the text does not flow around
the image.

On Thu, 01 Sep 2005 06:54:12 GMT, Spartanicus
Then you've made a mistake somewhere.


example:

The following works, but is not strict because of the image has the
attribute align=right (among other things)


[...]
<img
src="locket.jpg " alt="Locke" align="right"
height="85" width="75">
[...]
The following does not work at all (style="text-align: right;"),
perhaps because an image is not text. <img
src="locket.jpg " alt="Locke" style="text-align: right;"
height="85" width="75">

I would like it to look like the transitional does - where the text
flows around the right aligned image.


You're mistake is in thinking that text-align:right is the same as
float:right.

You need to *float* the image right, to make the text flow around it.

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Sep 1 '05 #9
James A. Donald <ja****@echeque .com> wrote:
> I can easily put the image on the right hand side in strict for
> example telling it to float right, but the text does not flow around
> the image.
Then you've made a mistake somewhere.


example:


Don't post code to the group, upload it, post the url.
The following does not work at all (style="text-align: right;"),


Duh, text-align is a different property than float.

--
Spartanicus
Sep 1 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1897
by: Greg Shannan | last post by:
I normally centre an image using a <p align="center"> ... </p> format, but I understand that this is "deprecated" in the latest standard in favour of styles. The problem is that I cannot find a style that will centre an image, "text-align" doesn't work and probably shouldn't. So what is the "standards-correct" method of centering an image? TIA .... Greg Shannan
18
4217
by: Heath | last post by:
Is it proper to center images in a <div> by using the text-align: center property? Or is there a better way?
2
2244
by: Ryan W Sims | last post by:
I'm having trouble with centering in IE... http://www.ryanwsims.com/koh/ The image should center over the text. It does in Firebird, but not in IE for some reason. If you look at http://www.ryanwsims.com/sd.php everything's fine (i.e. centered)
17
2516
by: Applebrownbetty | last post by:
Hi, I'd like to append/amend the following code from the Dreamweaver extension "Open Picture Window Fever" for the ability to center the PopUp window: By default, it allows the window to be offset on the left and top, but does not include a centering option. I'm thinking it would include something like (screen.width-imageWidth)/2; somewhere but not sure how do go about doing this.
6
2325
by: Jerry Camel | last post by:
I want to center an image on the screen and have text centered over the image. What's the best way to do this? I've been playing with style tags and I can get the stuff to center automatically OR have the text appear on top of the image. But in the second case, the image and text aren't centered properly. Any help is appreciated... Jerry
3
2086
by: The New iSoftware Company | last post by:
Any one know how to center a control like the image editors on the market (fireworks/photoshop/etc)? This way should support scrolling and zoom. Is there a way to draw overlays that is inverted from an image with out going pixel by pixel? LIke the title safe areas in premiere?
3
4214
by: John Pote | last post by:
1. Horizontal centering a <divin browser window. The current trend seems to be to place page content in a fixed width area in the middle of the browser window. How is this achieved? If I use a top level <divthen I can place it with CSS attribute 'left:', but this is a fixed offset. Is it possible to have a <divcentered in the browser window? 2. Verticle centering in <div>
2
3068
by: rudicheow | last post by:
SHORT VERSION ============= I have a bunch of identical fixed-size single-celled tables that rest against each other horizontally thanks to "float:left". These tables are dynamically generated and the number of them can vary greatly. They are all contained within a parent table cell, which is centred on the page. But I am unable to find a way of centering these table cells within the parent cell.
1
2290
by: =?Utf-8?B?ZnJhbmt5?= | last post by:
Hello, I've created a table that has two rows that are span across three columns. The third row has three columns, each with an image. The last row is also span accross three columns. The span rows are centering their data. however, the row with three columns, each with images (myimages1-3) are not centering with the rest of the table. Any idea why? Thanks in advance!
4
5293
by: harryusa | last post by:
I am trying to center 2 images concentrically which are z-indexed to lay on top of each other making an image with a border from another image that has a transparent center. I need the images to be horizonally and vertically centered within a <TD> </TD> area. No matter what I do the two image just present one above the other, albeit centered, NOT on top of each other. I originally did the entire page layout in TABLES until I found out I.E. 7...
0
9710
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9589
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10593
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7626
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.