简体   繁体   中英

Additional end anchor tags added after using link_to

For some reason rails is generating additional anchor tags after I use link_to inside an HTML anchor tag. Is this HTML design or rails constrain.?

<li>
                <a id="user-menu" href="#">
                    <%=current_user.first_name%>
                    <div id="bubblemenu" class="lotusBubble-content" style="display:none"> 
                      <ul>
                          <li><%= link_to "My Profile", current_user %></li>
                          <li>My Bookmarks</li>
                          <li>My Active</li>
                          <li>My Expired</li>
                      </ul>
                    </div>
                </a>
            </li>

This generates a HTML like this

            <li>
                <a id="user-menu" href="#">Srikanth</a>
                  <div id="bubblemenu" class="lotusBubble-content" style="display:none">
                              <a id="user-menu" href="#"> </a>
                              <ul>
                                    <a id="user-menu" href="#">
                                    </a>
                                    <li><a id="user-menu" href="#"></a><a href="/user.1">My Profile</a></li>
                                    <li>My Bookmarks</li>
                                    <li>My Active</li>
                                    <li>My Expired</li>
                              </ul>

why is there so anchor tags added automatically ?

这是由于您使用的是link_to指令,该函数在执行时会自动创建一个锚点ta

Just saw this restriction. Anchor inside an anchor is not permitted as per HTML standards. If at all something like that occurs, then the browsers atomically ends the outer anchor

http://www.w3.org/TR/html401/struct/links.html#h-12.2.2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM