-1

If i have a form in body with specific style and i want to exclude this form from this style(the body style) .

<body>
    <form id="form1" runat="server">
        <div class="demo-containers">
            <div class="demo-container" id="decorationZone">
                <h4>Student Schedule</h4>

                <fieldset>
                    <legend>Registeration Number</legend>
                    <label for="<%= UsernameBox.ClientID %>" runat="server">RegNum:&nbsp;</label>
                    <asp:TextBox runat="server" ID="UsernameBox" Width="150px" TabIndex="7"></asp:TextBox>
                </fieldset>
            </div>
        </div>
    </form>
......
</body>

The problem is : the body has a css and i want this style not applied on my form ,

Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392

3 Answers3

1

You could just override the style you dont want. Lets say that your body has a red background, so in your form just override the background color to white. I have created a small demo like this below.

Demo

body{
  background-color:red;
}
form{
  background-color:white;
}

There is a property called all in the CSS3 inheritance module. It works like this:

form {
  all: default;
}
adib.mosharrof
  • 1,624
  • 1
  • 12
  • 16
1

You can use CSS negation and leave out what you don't want to inherit from body:

body :not(form) { 
  background-color: red;
}
Andy Hoffman
  • 18,436
  • 4
  • 42
  • 61
0

unfortunately if you apply a body style on a page it will affect all the elements of the page. I think you can only redefine the property of your body in your form style. in the css you should recover your form that you want to exclude from your style

#form1

And you will have to overwrite the css property that you don't want.

jeremy-denis
  • 6,368
  • 3
  • 18
  • 35