CodeIgniter Forums
How do I get a span *inside* an anchor using CI anchor ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How do I get a span *inside* an anchor using CI anchor ? (/showthread.php?tid=50835)



How do I get a span *inside* an anchor using CI anchor ? - El Forum - 04-10-2012

[eluser]vincej[/eluser]
Hi - I am trying to use a particular CSS technique and the tutorial requires that you place a span inside an <a> anchor - easy when using HTML, but not so obvious when using CI. Example:

Code:
<ul>
   <li><a href="#">Buy Widgets <span></span></a></li>
   <li><a href="#">About Widget Corp <span></span></a></li>
   <li><a href="#">Contact Us <span></span></a></li>
  
</ul>

when I attempt to do it with CI the span falls either outside the anchor or if you follow the user guide placing the span inside the CI anchor,like this

Code:
echo anchor("welcome/cat/$topkey", $toplist['name'],"<span></span>");

then the span shows up in front of the label and one of the chevrons shows up on the page.

I have tried various combinations of double and single quotes.

Many Many thanks for any advice !


How do I get a span *inside* an anchor using CI anchor ? - El Forum - 04-10-2012

[eluser]CroNiX[/eluser]
Why are you putting it in the 3rd parameter (the attributes) of anchor()? Just append it to the 2nd parameter, which is the text of the link.
Code:
echo anchor("welcome/cat/$topkey", $toplist['name'] . '<span></span>');



How do I get a span *inside* an anchor using CI anchor ? - El Forum - 04-10-2012

[eluser]vincej[/eluser]
Thanks CroxNix - the obvious defeats me again ! It worked great !