Hello, this code bellow is a part of a mysql query wich puts out 6 images per row 75 * 75 in 4 rows, my problem is that whatever i put the TD to it wont line up in the center of the page but only in the left side of the page. why wont it center? :/ <td width="100" align="center"> <a target="_blank" class="add" href="<? echo PROFILE_ADD . $rowsSet['fid']?>"><img class="picture" src="<? echo IMAGE_PATH.$rowsSet['image']?>"</a><br> <a target="_blank" class="add" href="<? echo PROFILE_ADD . $rowsSet['fid']?>"><b>Add</b></a> | <a target="_blank" class="add" href="<? echo PROFILE_VIEW . $rowsSet['fid']?>"><b>View</b></a><br> <? // echo $rowsSet['dname']?> Points:<strong><? echo $rowsSet['today_points']?><br></strong><? } ?></td> HTML:
sorry i exmplained myself badly. it's the stuff in the TD that wont center, it's hugging the left side! and inside that TD is what i mentioned above.
There are two possible solutions i know which is if you are using the right attributes and value for <td> The <td> attributes are align, valign, colspan,rowspan,bgcolor,height, width; Which i think you did well, The second mistake might be from the browser you are viewing it with. try to view it in a multiple browser to see how it line up, if it is the same, then try validating that page with a DTD code if its .html or .htm page. Thirdly see if you can align the <table> tag to center and not <td>: You can create a new table within a table for it if you wish. If it doesnt help, then i hope somebody can come to the rescue here
might help to CLOSE the image tag, get rid of that target="" nonsense (there's a reason strict doctype deprecated that crap), stop opening and closing your php wasting overhead on switching parsing mode (and making the code a pain in the ass to read - I generally consider it bad code to have more than one <?php ?> on a page), not dump the SAME CLASS on every anchor when you've got a perfectly good TD around them, and you might also not want to put breaks inside inline-level elements... and there's no reason to state the same anchor twice when you could just make the image display:block; margin:0 auto; and condense the two anchors to one. Also, I'd check to see if the text-align is set in the CSS for the TD's, since that would override the inlined property (NOT that you should be inlining presentation in the first place) I'm guessing, but I suspect this is closer to what you are attempting to do: <?php echo ' <td class="add"> <a href="',PROFILE_ADD,$rowsSet['fid'],'"> <img src="',IMAGE_PATH.$rowsSet['image'],'" alt="" /> Add </a> | <a href="',PROFILE_VIEW,$rowsSet['fid'],'"> <b>View</b> </a><br /> ',$rowsSet['dname'],' Points: <strong>',$rowsSet['today_points'],'</strong> </td> '; ?> Code (markup): The CSS being: .add { width:100px; text-align:center; } .add img { display:block; /* force line break */ margin:0 auto; /* AND whatever you were doing with .picture */ } .add a { /* whatever you WERE doing with .add before */ } Code (markup): Mind you, that's a wild guess.
yeah maybe the class .add in your css file is overiding this center align?, just add the text-align:center; to the .add class as the guy said above it would probably solve the problem.