0

I have a Masterpage and I have a content page from this masterpage.. I must use different css for body tag for only this contentpage? How can ı do this?

this is my masterpage's css

body, div, ul, ol, li, p, h1, h2, h3, span, pre, a, img, blockquote, table, tbody, tfoot, thead, tr, th, td, pre, code { 
margin:0px; padding:0px; border:0 none; outline:0; vertical-align:baseline;}

I dont want this css code for my contentpage.. How can ı do this?

IrishChieftain
  • 15,108
  • 7
  • 50
  • 91
mekar10
  • 631
  • 1
  • 6
  • 16

3 Answers3

1

As far as im aware the only way you can do this would be to create a 2nd master page for this particular content page.

I would suggest removing the styles from the master page & include them in each content page as needed, your master page should apply to every page the same, without causing any issues

Ben
  • 163
  • 3
  • 18
  • This would create maintenance problems depending on the size of the site. I think your first suggestion of a separate master page is the most practical... unless CSS applied from the content page code-behind takes precedence over that specified in master page header? – IrishChieftain Sep 21 '11 at 15:36
1

You could create a control in the Master page with the CSS included. Such as:

<%@ Master Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 
    1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server" >
    <title>Master page title</title>
</head>
<asp:contentplaceholder id="CSS" runat="server">
<style type="text/css">
body, div, ul, ol, li, p, h1, h2, h3, span, pre, a, img, blockquote, table, tbody, tfoot, thead, tr, th, td, pre, code { 
margin:0px; padding:0px; border:0 none; outline:0; vertical-align:baseline;}
</style>
<body>

</body>
</html>

You could then place a Content control on the client page overriding the master and just omit the content control on the rest of the pages (they will inherit the default).

I would recommend using a separate CSS file instead of embedding it directly, but you can accomplish that easily as well.

Frazell Thomas
  • 6,031
  • 1
  • 20
  • 21
0

Sorry, but I'll suggest you include this css in the page you need it, not in the masterpage, since you don't want it in every pages... I guess this is not the answer you expected, but that's how CSS is work :S

Simon Arnold
  • 15,849
  • 7
  • 67
  • 85