Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide <label for=""> CSS

Tags:

css

label

hide

I am trying to hide these:

<p>
<label for="secondname"><?php esc_html_e('Last Name','wpestate');?></label>
<input type="text" id="secondname" class="form-control" value="<?php echo $last_name;?>"  name="firstname">
</p>

I managed to hide the Input, but not the label.

#secondname {
  display: none;
}

Thanks

like image 393
stemon Avatar asked Oct 13 '16 20:10

stemon


2 Answers

Use the attribute selector:

label[for="secondname"] {
    display: none;
}
like image 181
socki03 Avatar answered Nov 02 '22 11:11

socki03


Hiding the label with display: none; is bad for web accesibility and you shouldn't do it. Try visibility: hidden; instead.

like image 33
Jay Avatar answered Nov 02 '22 13:11

Jay