Jump to content

php align


chanfuterboy

Recommended Posts

hi,  echo 1 to 3, need to be center, and echo 4 need to be right, they are in the same line. how i can put it without use-ing   i try <td> also but seems not getting it help me

 

echo "<p align='center'>[<a href='profile.php' target='mFrame'>Profile</a>]  ";
echo "[<a href='profile.php' target='mFrame'>P.M</a>]  ";
echo "[<a href='profile.php' target='mFrame'>Add Friends</a>]      ";
echo "Welcome, ".$_SESSION['username']. "[<a href='logout.php'>Logout</a>]";

Link to post
Share on other sites

well start off trying to use divs to place your information

example

<div id="main_content">
     <div id="center" style="align:center"><?=echo "<p align='center'>[<a href='profile.php' target='mFrame'>Profile</a>]  ";?></div>     
     <div id="center" style="align:center"><?=echo "<p align='center'>[<a href='profile.php' target='mFrame'>Profile</a>]  ";?></div>
     <div id="center" style="align:center"><?=echo "[<a href='profile.php' target='mFrame'>Add Friends</a>]      ";?></div>
     <div id="right_side" style="float:right"><?=echo "Welcome, ".$_SESSION['username']. "[<a href='logout.php'>Logout</a>]";?></div>
</div>

Link to post
Share on other sites

well start off trying to use divs to place your information

example

<div id="main_content">
     <div id="center" style="align:center"><?=echo "<p align='center'>[<a href='profile.php' target='mFrame'>Profile</a>]  ";?></div>     
     <div id="center" style="align:center"><?=echo "<p align='center'>[<a href='profile.php' target='mFrame'>Profile</a>]  ";?></div>
     <div id="center" style="align:center"><?=echo "[<a href='profile.php' target='mFrame'>Add Friends</a>]      ";?></div>
     <div id="right_side" style="float:right"><?=echo "Welcome, ".$_SESSION['username']. "[<a href='logout.php'>Logout</a>]";?></div>
</div>

 

You cannot have multiple divs all with the same id.

Link to post
Share on other sites

It's invalid code.

 

It's also divitis - there is no reason for that many divs at all. One div wrapping all of those <p> tags is enough. If each <p> tag needs to be styled separately, it can be given it's own class.

 

And finally, making an ID or class name be a description of the styling is not a good practice, as at some point in the future, the styling may change. For example, the three p tags that are left aligned may need to be switched to a right alignment at some time, at which point having an ID or class named 'left' doesn't make a lot of sense.

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.