'How to have lots of textboxes to have similar properties in CSS?

I want the textboxes to have the same color and the same size. However, the textboxes don't seem to change when I do the CSS. I also would like to know how to do it for multiple textboxes as I'm planning to add a lot more textboxes.

My CSS:

   .TxtBox + .TxtBox{
              border-style: none;
              border-color: inherit;
              border-width: 0;
              position:absolute;
              outline: 0;
              height: 25px;
              width:530px;
              padding-left: 10px;
              background-color: rgb(204, 204, 204);
              top: 25px;
              left: 165px;
          }

And this is my Html using the Asp.Net framework:

   <asp:TextBox class ="TxtBox" ID="TextBox2" runat="server" Height="20px"></asp:TextBox>

  <asp:TextBox class="TxtBox" ID="TextBox1" runat="server" Height="16px"></asp:TextBox>


Solution 1:[1]

The "+" operator means "only the first child", so:

.TxtBox + .TxtBox{

means that you want to apply the style to the first textbox inside a textbox (assuming you set the class TxtBox to all of them)

Since you want to apply the style to all of the elements with that class, just do:

   .TxtBox {

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ricardo Aranguren