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?

1
  • Sorry to ask a stupid question, but why don't you want what looks like a routine reset for a particular content page? Commented Sep 21, 2011 at 15:20

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

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?
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.