Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6851149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:12:46+00:00 2026-05-27T01:12:46+00:00

Using this source code in a razor view: @for( int x = 0; x

  • 0

Using this source code in a razor view:

@for( int x = 0; x < 100; x++)
{
    <a href="action">link</a>
}
@for( int x = 0; x < 100; x++)
{
    @Html.ActionLink("link", "action")
}

Produces two different blocks of html:

The first loop produces <a> tags with a line break between each:

<a href="action">link</a>
<a href="action">link</a>
<a href="action">link</a>
<a href="action">link</a>
<a href="action">link</a>
<a href="action">link</a>
<a href="action">link</a>
<a href="action">link</a>
<a href="action">link</a>
...

And the second one produces one long chain of <a> tags:

<a href="action">link</a><a href="action">link</a><a href="action">link</a><a href="action">link</a><a href="action">link</a><a href="action">link</a><a href="action">link</a>...

In the second case, browsers will not use any spacing between the links and will not allow the text to wrap if necessary creating one long non-breakable line of links. The fact that there is no space in the link text makes a difference. In my application, I’m really need a long list of one-word links and they have to wrap correctly.

What is the right way to use Html.ActionLink in this case?

I found two workarounds:

  1. Wrap the <a> inside <li>
  2. Use <text></text> after the Html.ActionLink call. That forces a line break in the generated source code.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:12:47+00:00Added an answer on May 27, 2026 at 1:12 am

    From a semantic point of view you’re creating a bunch of links that form some kind of navigation. You should express that semantics in your generated HTML, so your so called work around with the <li> element is the “right” approach from a semantic point of view!

    In HTML5 we have a tag to express that there is a bunch of links that forms some kind of navigation on your page:

    <nav>
      <ul>
        @for( int x = 0; x < 100; x++)
        {
          @Html.ActionLink("link", "action")
        }
      </ul>
    </nav>
    

    If you’re using (X)HTML 4 you may consider to use a <div class=”nav”> element instead.

    Last point: Don’t try to express some representation with your HTML code. The wrapping of HTML links is a representation thing. If you use semantic markup you may fix the representation too but that’s not the reason to use semantic markup.

    How you can use HTML 5 tags even with IE6 is demonstrated in this link.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code for detect the source language.. jsonObj = new JSONObject(response);
I am using this http://imthi.com/blog/programming/iphone-rss-reader-application-with-source-code.php as a start for my rss reader in my
We are using a tool which generates source code. This source code is submitted
I have download the source code of gcc, using this command: svn checkout svn://gcc.gnu.org/svn/gcc/trunk
I want to get the difference between two images I use this source code:
I am using MVC3 (Razor) with the Paging open source code here . The
I have something like in MVC (I am using MVC c# using razor): @Html.ActionLink(Edit,
I am actually using this calendar source code, but I did encountered a problem
I'm trying to parse strings that represent source code, something like this: [code lang=html]
I am using this source code as my base and trying to change the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.