Anchor tags in pages

Whenever I put an anchor on a page, it creates a link that encompasses the next word on the line. For example, if I have a section on my page called “Computer Labs and Hours”, and I want to give it the anchor “complabs”, I’ll usually put the anchor right before the title of the section. The html I expect to see should be like this:

<a name="complabs" id="complabs"/>Computer Labs and Hours

Or even:

<a name="complabs" id="complabs"></a>Computer Labs and Hours

Instead, the html generated by CM1 looks like this:

<a name="complabs" id="complabs">Computer</a> Labs and Hours

…which turns the word “Computer” into a hyperlink (and is rather undesirable). Am I just doing it wrong, or is this a known issue?

How are you creating these links? It is easiest to use the rich text widget. Highlight the text you want to anchor to using the anchor icon. Then go to the place you want to link from select this text and choose anchor from the drop down when creating the link to the anchor.

I don’t quite think you understand. When I want an anchor point, I don’t want to change the appearance of any text, I just want to place an (invisible) anchor at a certain place in the document… say, at the start of a certain line.

Using the example from my first post on this thread, I would put my cursor to the left of the words “Computer Labs and Hours”, click the anchor button in the rich text widget edit window and fill in “complabs” for the name of the anchor. As expected, a little anchor icon shows up in the edit.

However, when I save my work and preview the page, the word “Computer” in the phrase “Computer Labs and Hours” has been turned into a link. If I go back to edit the page and click “view code”, I can see why – the anchor tag is (unexpectedly) wrapped around the word “Computer” like so:

<a name="complabs" id="complabs">Computer</a> Labs and Hours

…which does not make an invisible anchor tag. It turns the word “Computer” into a hyperlink.

I would expect to see either this:

<a name="complabs" id="complabs" />Computer Labs and Hours

(which would be more preferable since it makes cleaner code)

…or this:

<a name="complabs" id="complabs"></a>Computer Labs and Hours

(which is more likely what a cms would generate)

Hello,
Are you still experiencing this issue? If so, I would be happy to assist you in finding a resolution.
Best,
-Jon

As a follow up to this: The wrapping of text with an anchor tag is best practice for compatibility reasons and is the reason the editor wraps the anchor tag around the first word closest to it. Without doing that, not all browsers (namely IE) will read the anchor tag. According to the W3, empty tags should be supported in browsers, but this is not 100% yet (see final note: http://www.w3.org/TR/html4/struct/links.html#h-12.2).

The best approach would be to modify the style of the bookmark in the text using CSS so it does not appear as a hyperlink and disrupt the flow of the content. Trying to work around the anchor tag being wrapped around the text, though, might leave some visitors stranded when it comes to the bookmark.