Label's Background Color

Malam Malam 121 Reputation points
2022-02-17T18:28:07.373+00:00

How do I set a lable's background color to highlight ONLY the text, not the padding or spaces before and after the text?
I've tried the following but it highlight the space before the label

![<style>  
    .auto-style1 {  
    width: 18.4em;  
    background-color:red;  
    }  
    .input1[type="text"]{  
        width: 40em;  
    }  
  
</style>  
<p>  
    <label class="auto-style1" for="txtName">NAME:</label>  
    <input class="input1" type="text" id="txtName" name="tbName" />  
</p>][1]  
  
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,319 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yijing Sun-MSFT 7,071 Reputation points
    2022-02-18T05:22:42.177+00:00

    Hi @Malam Malam ,
    Could you post your result? I suggest you could press F12 when you run the page and you could look at your elements.
    175691-test1.png

    Best regards,
    Yijing Sun


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments