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

  • SEARCH
  • Home
  • 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 7531277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:07:47+00:00 2026-05-30T05:07:47+00:00

I use ASP.NET MVC 3. For my forms, I align the label’s text to

  • 0

I use ASP.NET MVC 3. For my forms, I align the label’s text to the right. Also, there is a colon between the label and the input field.

Firstname: [          ]
     Last: [          ]

Can I automatically insert this colon using CSS or some C# code in MVC 3?

The best thing I came up with so far is to use the [Display(Name="Firstname:")] attribute, but this has the side effect of also including this colon in validation messages:

[Required]
[Display(Name = "Firstname:")]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} character long.", MinimumLength = 1)]
public string Firstname { get; set; }

The other alternative was to use the LabelFor() method overload, but this forces me to specify the label text twice (once in the Model and once in cshtml file):

<div>
    <div class="editor-label">@Html.LabelFor(x => x.Firstname, "Firstname:")</div>
    <div class="editor-field">@Html.TextBoxFor(x => x.Firstname)</div>
</div>

Any better suggestions?

  • 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-30T05:07:48+00:00Added an answer on May 30, 2026 at 5:07 am

    Through CSS, you can add the colon via the after pseudo class. You can find more information about this pseudo class here.

    .editor-label > label:after {
        content: ": "
    }
    

    Working example: http://jsfiddle.net/fJQDZ/

    Please note that the after pseudo class is not available in IE7.

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

Sidebar

Related Questions

I want to use forms authentication in my asp.net mvc site. Can I use
I have decided to use ASP.NET MVC to develop multi page (registration) forms in
Possible Duplicate: Can I use ASP.NET MVC together with regular ASP.NET Web forms Let's
I want to use forms authentication in asp.net mvc applications. I have searched a
I'm deciding between using ASP.NET MVC, or standard ASP.NET Web Forms with URL routing
I currently use the default forms authentication method for my ASP.NET MVC application. above
I am trying to implement Logout Functionality in ASP.NET MVC. I use Forms Authentication
I use asp.net mvc & going to build javascript files at application startup depending
I have tried to use ASP.NET MVC for a while, then I face a
I am attempting to use ASP.NET MVC 4 beta together with JSON.NET. I'm using

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.