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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:27:57+00:00 2026-06-17T23:27:57+00:00

Imagine the following illustrative HTML: <form> <div class=line> <label class=lbt for=name>Name:</label> <span class=obr>*</span> <input

  • 0

Imagine the following illustrative HTML:

<form>
<div class="line">
    <label class="lbt" for="name">Name:</label>
    <span class="obr">*</span>
    <input id="name" class="inp" type="text" />
    <span class="err">Missing!</span>
</div>
<div class="line">
    <label class="lbt" for="area">Area:</label>
    <input name="area" class="inp" type="text" />
    <span class="suf">m<span style="vertical-align: super;">2</span></span>
    <span class="err">Missing!</span>
</div>
</form>

By client requirement, both the label and the span with the obligatory indicator must be in the same line, being the input and the rest of the spans in the next line.
The obligatory indicator must be right after the label text and the other spans right after the input element.

Sadly I can’t change the HTML code or I would put the obligatory element inside the label and use a display: block style (or wrap both in a span and do the same).

I tried using the .obr::after to create a line break but since this element doesn’t always exist and I can’t use ::before in an input element so I tend to believe using content isn’t feasible unless there’s a way to put it conditionally (.lbt::after or in .obr::after if exists). Here’s a jsfiddle with this problem.

I also tried float and positions approaches but haven’t found a good generic solution that could fit any label or input size.
I may consider using jQuery for this, but I would prefer a simpler approach only by CSS.

Been almost two days trying to find a good solution…

  • 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-06-17T23:27:58+00:00Added an answer on June 17, 2026 at 11:27 pm

    label and the * <span> right beside each other.

    <input /> and the other <span> beside each other on another line.

        .line
        {
            border: 2px solid black;
            padding: 5px;
            overflow:hidden;
        }
    
        .line .obr
        {
            color: Red;
            font-weight: bold;
            float:left;
        }
    
        .lbt
        {
            float:left; 
         }
        .line .obr::after
        {
            content: '\A';
            white-space: pre;
        }
        .inp
        {
            float:left; clear:both;
            margin-top:5px;
    
        }
        .line span
        {
            float:left;
        }
    

    Check this out : http://jsfiddle.net/AliBassam/2LqCc/

    If you want the <span> beside the <input /> to be lower then add margin-top:5px;

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

Sidebar

Related Questions

Imagine the following HTML: <div> <b></b> <div> <table>...</table> </div> </div> <!-- this one -->
Imagine the following scenario: class MyClass extends OtherClass<String>{ String myName; //Whatever } class OtherClass<T>
Imagine the following database: Table 'companies' has fields id, name and flagship_product_id. Table 'products'
Imagine the following class that manages a resource (my question is only about the
Imagine the following classes: Class Object(threading.Thread): # some initialisation blabla def run(self): while True:
Imagine the following code, written in C#: public class Provider<T> { T GetValue(); //
Imagine the following code: class SimpleLetter def values (a .. z).to_a end def ===(other)
Imagine the following scenario: template<class T> void myFunction(T *) { //do nothing } void
Imagine the following situation: class IAlarm : public boost::enable_shared_from_this<IAlarm> { boost::shared_ptr<IAlarm> getThisPointerForIAlarm() { return
Imagine the following code: MyService myService = new MyService(); myService.Start(); myService.DoStuff(); The MyService class

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.