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 211705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:07:10+00:00 2026-05-11T18:07:10+00:00

The error label displays till the width of the table. As this: alt text

  • 0

The error label displays till the width of the table. As this:

alt text http://img518.imageshack.us/img518/8864/width1.jpg

How can I display it till the text of the label? This is the css:

 label.error    { color: red; font-size:16px; font-family:Nyala; background-color: #FFFFCC; display:block; width:auto; }
  • 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-11T18:07:10+00:00Added an answer on May 11, 2026 at 6:07 pm

    This works, without adding any extra divs (though admittedly there is an extra span (.errorMsg) to contain the error-message:

    Using XHTML 1.0 strict doctype.

        <style>
    
            #container
                {width: 50%;
                margin: 0 auto;
                }
    
            label   {display: inline-block;
                width: 48%;
                text-align: right;
                }
    
            input   {display: inline-block;
                width: 50%;
                }
            .errorMsg
                {display: block;
                width: 51%;
                margin: 0 0 0.5em 49%;
                color: #f00;
                background-color: #ffa
                }
    
        </style>
    
    ...
    
        <div id="container">
    
            <form>
    
                <label for="input1">Label 1</label>
                    <input type="text" id="input1" name="input1" />
                    <span class="errorMsg">Error message</span>
    
                <label for="input1">Label 2</label>
                    <input type="text" id="input2" name="input2" />
                    <span class="errorMsg">Error message</span>
    
            </form>
    
        </div>
    

    It’s worth noting that the width of the .errorMsg is 51%, not 50%, to accomodate the borders of the input (being added to the 50% width defined in the CSS. That may just be FF3.x on Ubuntu 8.04, though. I’ve not tested exhaustively. Or much at all, I’m afraid. YM, as always, MV.

    Demonstration at: http://www.davidrhysthomas.co.uk/so/errorLabels.html.

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

Sidebar

Related Questions

When I run this code I get the following error error: invalid label html_attributions
I created this simple login page. It's supposed to display in the label text
Why am I getting an undefined label error in following code? (I am leaving
error not firing. but its showing on firebug HTTP 500 error : jQuery15105771912402844872_1324698623378({Message:Master Order
I have this strange error I don't understand. I have a model User defined
I have successfully created a textbox that displays / collapses an error message depending
I am trying to create an event handler which displays some text whenever a
I am using the jQuery validate plugin . My error labels are styled like
I have writen some code in VBA (Excel) with error handling labels. It worked
I have a few labels on my page with a class of 'error', 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.