Forum Moderators: coopster

Message Too Old, No Replies

Echoing white space to the left?

I need to "indent" a list of rss links

         

Furious Styles

4:29 pm on May 2, 2005 (gmt 0)

10+ Year Member




echo "<a class='.rss' href=$url>$title</a></li><br>
";

CSS won't provide a uniform indent, only the first line in a body within the element. I need to scrape my links away from the side of their div. Is there a code to send white space in the echo?

Thanks in advance.

gettopreacherman

4:56 pm on May 2, 2005 (gmt 0)

10+ Year Member



echo "<a class='.rss' href=$url>&nbsp;&nbsp;$title</a></li><br>";

Stormfx

5:00 pm on May 2, 2005 (gmt 0)

10+ Year Member



The browser will only show a single space at a time unless it's in a <pre></pre> block.

Just add a margin to your a class:

.rss {
margin: 0px 10px;
}

Then the new code would be:

echo '<a class="rss" href="'.$url.'">'.$title.'</a></li><br>';

Note the typo in & reformating of that line, class='.rss' should be class='rss' and also, the ' character is not a vaild HTML quote.

If you want to use double quotes for the statement, make sure you use double quotes in the link and escape them, as so:

echo "<a class=\"rss\" href=\"$url\">$title</a></li><br>";

Furious Styles

5:46 pm on May 2, 2005 (gmt 0)

10+ Year Member



I just bumbled into the answer:


<div id="us" style="white-space:pre;"><h4><font color="white"> All the news that fits, as they say:</font></h4>
<?php
//YAHOO
$url = 'http://rss.news.yahoo.com/rss/us';
if ( $url ) {
$rss = fetch_rss( $url );
$i=1;
foreach ($rss->items as $item) {
$href = $item['link'];
$title = $item['title'];

if(strlen($title) > 60)
{
$title = substr($title,0,60)."...";
}

echo "<a href=$href target='_top' class='topicimport'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$title</a><br
/>";
$i++;
if ($i == 11)
{
break;
}
}
}
?>
</div>

The HTML gets spaced via the pre style, but the spacing gets done on the browser side of the php, not the server end. That code that I pasted had to be altered for Safari, which insisted in honoring ALL the white space between the php?> expression end and the <div> front and back tags.

Thanks for your help!