Jump to:

22997 Posts in 11853 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Anchor Tags with  

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1986 Views
  • edwardlewis
    Avatar
    Community Member
    32 Posts

    Anchor Tags with   Link to this post

    I have tried adding some anchor tags using the editor and cant work out how to do it.. whenever I put them in, it creates a link with a space in there, eg:

    <a name="name-of-link">&nbsp;</a>

    Is there a reason for this or a way to stop it?

  • martimiz
    Avatar
    Forum Moderator
    1038 Posts

    Re: Anchor Tags with &nbsp; Link to this post

    I think this a TinyMCE issue rather then a SilverStripe one. TinyMCE is set to not accept emty tags like that, so it'll add a non-breakable space to it. If you really want it removed you should probably look on the TinyMCE forums...

    But on some browsers an empty anchor tag wouldn't even work. Would it be a good idea to move the anchor to a spot where the space doesn't hurt, like at the end of an article title?

  • Jedateach
    Avatar
    Forum Moderator
    227 Posts

    Re: Anchor Tags with &nbsp; Link to this post

    I have a similar problem where the anchor tags are showing an underlined space.

    html produced by tinymce/ss insert link:

    <h2><a name="myanchor">&nbsp;</a>My heading here</h2>


    produces:

    _My heading here

  • martimiz
    Avatar
    Forum Moderator
    1038 Posts

    Re: Anchor Tags with &nbsp; Link to this post

    An anchor tag is just another <a>...</a> tag and by default these appear underlined, even for spaces... So apart from getting rid of the added $nbsp; all together, you'll probably have to handle this in css.

    Btw: you can disable the automatic addition of the nonbreakable space from an empty anchor. In cms/config.php:

    valid_elements' => "@[id|class|style|title],#a[id|rel|...

    becomes

    valid_elements' => "@[id|class|style|title],a[id|rel|...

    But (some?) browsers will now show the text to the right of the anchor as a link, thinking you must have misplaced the anchor's end tag - all this apart from the discussion that there shouldn't be any empty tags in HTML. Replace the &nbsp; with a <!-- anchor --> will not work: /sapphire/javascript/tinyMCE_improvements.js->sapphiremce_cleanup() will strip them out. So again, wherever possible I just put my anchors to the right of the text...

    1986 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.