Centering

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
duranike
Forum Newbie
Posts: 17
Joined: Tue Nov 04, 2003 8:40 pm

Centering

Post by duranike »

how do i center this in a php file when called in a browser?

Code: Select all

print"<img src="error_fill_user_serial.gif">";
duranike
Forum Newbie
Posts: 17
Joined: Tue Nov 04, 2003 8:40 pm

Post by duranike »

anyhelp? i have some html tables too that are going to the right
SBukoski
Forum Contributor
Posts: 128
Joined: Wed May 21, 2003 10:39 pm
Location: Worcester, MA

Post by SBukoski »

I recommend buying a good HTML book. There are plenty of ways to center an image.

You coulde use the <p> or <div> tags, for starters.

Code: Select all

<p align="center"><img src="my_image.gif"></p>
<div align="center"><img src="my_image.gif"></div>
If it's in a table, set the table cell to centered.

Code: Select all

<table>
  <tr>
    <td align="center"><img src="my_image.gif"></td>
  </tr>
</table>
And then there is always style sheets and other methods left that I didn't mention.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Code: Select all

print "<center><img src="error_fill_user_serial.gif"></center>";
im not really sure what you meant.. but is that what you wanted?
SBukoski
Forum Contributor
Posts: 128
Joined: Wed May 21, 2003 10:39 pm
Location: Worcester, MA

Post by SBukoski »

I recommend against using the <center> tag as it is deprecated as of HTML 4.0. Some of the examples I gave might even be deprecated. The recommend using style sheets now-a-days. But browsers still recgonize all the deprecated alignment tags, and they are still widely used, so it doesn't hurt.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

i use td align="center" when im aligning a list of things or just a whole cell, but most the time it's just one line of text, and <p align="center"> adds too much spacing..

oh, and ive never tried css for alignment :P
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

use sumthing like this: <span style="color:blue;font-weight:bold;"></span>
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

i know how to use css, i just never used it for ALIGNMENT :D
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Wouldn't that be

Code: Select all

print '<img style="text-align:center;" src="error_fill_user_serial.gif">';
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

ok. as i read this i was thinking "why are they saying to use the deprecated align tag?" then "why the dprecated in html 4.01 and unsuported in xhtml center tag?"

use what jam said. in a year or so it'll be the only one that works...
SBukoski
Forum Contributor
Posts: 128
Joined: Wed May 21, 2003 10:39 pm
Location: Worcester, MA

Post by SBukoski »

I doubt that'll it'll be the only one that works in a year. They are in such wide use that I think it'll be several years before we even start to see them go away and become unsupported. However, you are correct in that it should be done using the STYLE tags; just to be on the safe side.

Up until a few months ago I never used style tags. Now my entire site (or most of it) is all style tags. Makes it easier to read anyways.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

classes and a stylesheet that you import is easier to maintain when you have a bunch of things cross pages that are the same.

also allows one to use style as needed to tweak.


fyi on centering:

text-align:center
works for tables in M$IE because it's buggy. to center everything in a body,

Code: Select all

body &#123;
  text-align:center;
  margin:auto; /* this can be broken into right and left */
&#125;
Post Reply