ndjustin20 Posted May 15, 2008 Share Posted May 15, 2008 Can someone tell me why the following code won't center the link $msg = '<a href="http://www.gaf.com/General/GafMain.asp?Silo=RES1&WS=GAF&App=ROOF&Force=shingle-lines.asp"> <font "color="#000066" size="+3"><center>GAF-ELK Shingle Styles & Colors</center></font></a>'; Quote Link to comment https://forums.phpfreaks.com/topic/105837-link-wont-center-when-using-variable-to-store/ Share on other sites More sharing options...
gizmola Posted May 15, 2008 Share Posted May 15, 2008 You need to learn about the difference between Block and inline elements. An anchor is an inline element. Hopefully this will help: http://www.webdesignfromscratch.com/css-block-and-inline.cfm Also the center tag is deprecated, meaning that you should be using css and not center. Quote Link to comment https://forums.phpfreaks.com/topic/105837-link-wont-center-when-using-variable-to-store/#findComment-542454 Share on other sites More sharing options...
ndjustin20 Posted May 15, 2008 Author Share Posted May 15, 2008 Looks like I will need to read up on css before figuring this out. Thank you for the advice. Quote Link to comment https://forums.phpfreaks.com/topic/105837-link-wont-center-when-using-variable-to-store/#findComment-542459 Share on other sites More sharing options...
Guardian-Mage Posted May 15, 2008 Share Posted May 15, 2008 an easy solution is this: #This uses inline divs $msg = '<div style="color:#000066;text-align:center;"><a href="http://www.gaf.com/General/GafMain.asp?Silo=RES1&WS=GAF&App=ROOF&Force=shingle-lines.asp">GAF-ELK Shingle Styles & Colors</a></div>'; It will make a new line for the link. I hope it helps, and please mark your topic as solved. W3Schools is a good place to learn css Quote Link to comment https://forums.phpfreaks.com/topic/105837-link-wont-center-when-using-variable-to-store/#findComment-542464 Share on other sites More sharing options...
gizmola Posted May 15, 2008 Share Posted May 15, 2008 Well, hopefully the main point is, that a link by itself is "inline". In other words, it conforms to the flow of the "block" that contains it. If that block element (a paragraph or div perhaps) is centered, then the link will be centered. If it's a td in a table, ditto. With that said, I hardily endorse not using the deprecated font and center tags, as this will fail standards validations and just make you look like a noob Quote Link to comment https://forums.phpfreaks.com/topic/105837-link-wont-center-when-using-variable-to-store/#findComment-542465 Share on other sites More sharing options...
ndjustin20 Posted May 15, 2008 Author Share Posted May 15, 2008 yeah still new......the code provided in the above example didn't work either....I am inputing the data into this table: <table> <td width="240" bgcolor="#CCCCCC"><p><a href="services.php"><font color="#9999FF" size="+3"><center>Services</font></a></p> <p><br /> <br /> </p> <p><a href="testimonials.php"><font style="vertical-align:top" color="#9999FF" size="+3">Testimonials</font></a></p> <p><br /> <br /> </p> <p><a href="resources.php"><font color="#9999FF" size="+3">Resources </font></a></p> <p><br /> <br /> </p> <p><a href="materials.php"><font color="#9999FF" size="+3">Materials</font></a></p> <p><br /> <br /> </p> <p><a href="insurance.php"><font color="#9999FF" size="+3">Insurance</font></a></p> <p><br /> <br /> </p> <p><a href="warranty.php"><font color="#9999FF" size="+3">Warranty</font></a></p> <p><br /> <br /> </p> <p><a href="contract.php"><font color="#9999FF" size="+3">Contract</center></font></a></p> <p><br /> </p></td> <td align="left" valign="top"><font color="#006699"><?php echo "$msg"; ?></font></td> </table> and it still won't center no matter what I use to try to make it center. Here is the original code again: $msg = '<a href="http://www.gaf.com/General/GafMain.asp?Silo=RES1&WS=GAF&App=ROOF&Force=shingle-lines.asp"> <font align="center" "color="#000066" size="+3">GAF-ELK Shingle Styles & Colors</font></a>'; Quote Link to comment https://forums.phpfreaks.com/topic/105837-link-wont-center-when-using-variable-to-store/#findComment-542473 Share on other sites More sharing options...
ndjustin20 Posted May 15, 2008 Author Share Posted May 15, 2008 Is it because of td align="left" that the link won't center. I want the table to align left and top. Maybe I have it wrong though? Quote Link to comment https://forums.phpfreaks.com/topic/105837-link-wont-center-when-using-variable-to-store/#findComment-542475 Share on other sites More sharing options...
ndjustin20 Posted May 15, 2008 Author Share Posted May 15, 2008 Quote Link to comment https://forums.phpfreaks.com/topic/105837-link-wont-center-when-using-variable-to-store/#findComment-542477 Share on other sites More sharing options...
gizmola Posted May 15, 2008 Share Posted May 15, 2008 Exactly, as I stated previously. The td is your block container, so the link is conforming to its flow. Quote Link to comment https://forums.phpfreaks.com/topic/105837-link-wont-center-when-using-variable-to-store/#findComment-542483 Share on other sites More sharing options...
ndjustin20 Posted May 15, 2008 Author Share Posted May 15, 2008 So how do I center it with changing the block? Quote Link to comment https://forums.phpfreaks.com/topic/105837-link-wont-center-when-using-variable-to-store/#findComment-542504 Share on other sites More sharing options...
gizmola Posted May 19, 2008 Share Posted May 19, 2008 For that TD align="center" Quote Link to comment https://forums.phpfreaks.com/topic/105837-link-wont-center-when-using-variable-to-store/#findComment-545037 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.