Centering a Graphic on the page with CSS

Results 1 to 2 of 2

Thread: Centering a Graphic on the page with CSS

  1. #1
    Join Date
    Dec 1969

    Default Centering a Graphic on the page with CSS

    This is a repeat of a message I posted a couple of days ago, without getting any response. However, access problems caused me to post it then in an existing thread with a related, but distinct, subject; so I&#039;m trying again in a new thread.<BR><BR>What&#039;s the approved &#039;modern&#039; method, using CSS, to get a graphics image centered vertically (i.e. "left", "center", "right") on your page? <BR><BR>Without CSS, I can simply wrap the image inside a &#060;div&#062; tag with an align="center" attribute, but that option isn&#039;t available when I&#039;m specifying a CSS. Yet, I am told that the attribute &#039;align="center"&#039; is "deprecated in favour of a CSS approach".<BR><BR>What do I have to in a CSS to center a graphic?

  2. #2
    Join Date
    Dec 1969

    Default RE: Centering a Graphic with CSS -Two ways

    I. Images are considered inline elements. So you can use "text-align" to center them.<BR><BR>ex.<BR>&#060;div style="text-align:center;"&#062; <BR><BR>II. Use CSS to make the image a block level element and then use margins to center it.<BR>ex.<BR>&#060;img src="whatever.gif" style="display:block; margin:auto;"<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts