View Full Version : PHP and CSS

04-21-2007, 03:32 AM
how can I change the style of this code to align 10px to the right?

echo " <span class=\"leftfloat\">$artist_name_next[$i] </span>"

I tried adding Style='left:10px;' but that didn't take.

Any suggestions. CSS and PHP together give me a headache sometimes

04-21-2007, 04:22 AM
I think you need to set a positioning type:


(Or instead of relative you could use absolute, fixed, or float, depending on what you need. See [/URL][URL="http://www.w3schools.com/css/pr_class_position.asp"]W3Schools' artice (http://www.w3schools.com/css/pr_class_position.asp) on this for more information.)

04-21-2007, 10:39 AM
PHP and CSS have nothing to do with each other, PHP outputs HTML with may include CSS but its not a PHP issue, view the source of the PHP output (the HTML) and debug that instead.

PS: if $i is not an integer you need to add some braces or concatenate (I suggest using braces anyway)

echo " <span class=\"leftfloat\">{$artist_name_next[$i]} </span>";

04-21-2007, 01:14 PM
Yes, PHP is not the problem, for that matter you could just say

<span class="leftfloat"><?php echo($artist_name_next[$i]);?></span>
If you want to move it to the right by 10px without using absolute positioning you should give it a margin-left:10px; in the CSS.