I would like to insert a piece of CSS to a Page Layout, to let it style the page but only when it is in the editing mode. Is there anyway to achieve that? I know there is a Editing mode Panel, but how could I insert CSS to it?

Version = 2013

1 Answer 1

<asp:Content contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">

    <PublishingWebControls:EditModePanel runat="server">

        <!-- with the built-in control -->
        <SharePoint:CssRegistration Name="somepath/somecss.css" runat="server" />

        <!-- classic -->
        <link href="<%$ SPUrl:~siteCollection/somepath/somecss.css %>" type="text/css" rel="stylesheet" />

        <!-- inline -->
            #sideNavBox {
                display: none;

            #contentBox {
                margin: 0;


  • I didn't follow this verbatim, but I used the rationale behind this and used the snippet code generated from sharepoint. Thank you! Very helpful. A side note is that I need to wrap the <style> tags in some other tag I'm not sure of, such as <!--MS:<style type="text/css">--> #somediv {display:none;} <!--ME: </style>-->
    – photonacl
    Feb 4, 2016 at 16:19

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.