Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

CSS Need some help in CSS

Diallo

New Coder
Hello everyone!

I'm a new guy in CSS and currently working on a project and would appreciate if someone could help me solve a little issue i'm facing. I can only use CSS to do the task. Basically there’s a wording on top of the content box that says " Write a reply " (See image below) on a website. I would like to add the text " No spam please " next to that wording using CSS. So i tried the code below but it’s not working. If i remove the [write a reply:] it will work and add the text but accross the entire website where there's labels. I need the text to be added just next to the label containing “Write a reply”. Can anyone help in correcting the code below, i’m not an expert just trying to get this fixed. Thank you!

CSS:
.label[Write a reply:]::after {
  content: ‘No spam please’;
  font-weight: bold;
  color: red;
}


CSS syntax.png
 
Last edited by a moderator:
I think that .label[Write a reply:] is invalid CSS syntax. So the entire property simply gets ignored, whereas it works when you remove that.
Now if you want this particular label to work differently from all other labels you need to give it a specific id or class. Personally I'd not do this in the label, but use a placeholder in the input element itself, like this

HTML:
<input  placeholder="No spam please">

which not only looks more professional, but forces the user to see it before typing (whereas they might not really be looking at the label).
 
Hey thanks for the reply, if i use the placeholder as suggested, what would i modify on the previous code that i wrote? I'm not really familiar with placeholders, i'm really kind of new to this. Can you please show me the easiest/simplest way of making it work?
 

Latest posts

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom