Question

I have a master page which has an exteral css page in the header. Includes the height of the pages, however only one page needs to be longer. So I figured inline css would be the best option over creating a whole other master page or creating a new css page that only has one line different. I looked through this site for an answer but ive only found how to change the external css link to one page, but like i said i dont want to add a whole new different page, I only need the hight property of the pages to be changed so is there a way to just override it by something similar to inline css? or is a new css page the only option?

Was it helpful?

Solution 2

If you want a certain page to have just one difference, you don't need to copy and paste the whole stylesheet over to a different stylesheet. As long as it is included after (i think) the first stylesheet being included, all you need to put is the changes you want.

If you want to put a small bit of CSS on a HTML page without having a stylesheet, simply put it in

<style type="text/css">
css code here
</style>

I hope this works,

-Ben

OTHER TIPS

If you are trying to add in the HTML page (seattle.html) then use the below code

<!--MS:
<style type="text/css">-->
#contentBox{ margin-left: 0; margin-right:0; width:100%; min-width:0; }  #contentRow{padding-top:0;}
<!--ME: </style>-->

First of all, you're talking about master pages, which are part of asp.net, not classic asp, so I'm retagging your question accordingly.

asp.net allows you to give the style tag the runat = server property. In header of am aspx page you could add

<style type="text/css" id="sitestyle" runat="server"></style>

In the codebehind you can then populate this as follows

sitestyle.InnerHtml = (your server generates css styles here);

Edit - master page with two content placeholders

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" %>

<html>
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="ContentPlaceHolderHead" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>
     If You want to use the Inline css then you can use that inside the <style> tag.

But Inline and Internal css is not the good option. Because being as a good developer It is always a good practice that you use External css.

It will really help you to reuse your css.

&

Biggest Advantage is it will make your code more maintainable.
I hope this will help you.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top