0

I am trying to put inline css into an mvc page which inherits from a master page. I want to do this because this css is page specific and I feel it shouldn't go into a site wide file. What is the best way of doing this. My failed attempt is below. Nothing on the site will recognize testTwo styling. Thank you

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
        .test
        {
        }
        .testTwo *
        {
            float: left;
            padding: 5px;
            border: 2px solid gray;
            margin: 3px;
        }
    </style>
</asp:Content>
0

2 Answers 2

2

missing the opening <style> tag? bad copy-paste, not the issue


Where is this ContentPlaceHolder at in your MasterPage?

Often times the TitleContent ContentPlaceHolder is inside the <head> tag within the <title> element like so:

<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>

Is this the case? If so, those styles will not be interpreted since browsers won't recognize the styles within <title><style>..</style></title>


I would suggest updating your MasterPage like this:

<head>
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
    <link.... />
    <link.... />
    <asp:ContentPlaceHolder ID="StylesheetContent" runat="server" />
    <script.... />
    <script.... />
    <asp:ContentPlaceHolder ID="ScriptContent" runat="server" />
</head>
Sign up to request clarification or add additional context in comments.

1 Comment

bad copy and paste. Thank you for noticing
0

Where is your opening

<style type="text/css">

?

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.