SharePoint 2013: Inline Styles in Design Manager Page Layout

When you begin working with Page Layouts in SharePoint 2013 Design Manager available in Publishing site, you may want to start adding inline styles like you used to do in SharePoint 2010 to hide the left quick launch among many other reasons. Easy enough, you create a custom Page Layout in Design Manager, say named “Inline Page Layout”, and SharePoint creates two files for you, inline-page-layout.html and inline-page-layout.aspx. As we know, we are not supposed to touch the aspx file, only the html file. No problem.
Open the html file and in thesection we find a content placeholder,

 <!--MS:<asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server">-->

Within this content placeholder, we wish to add our inline style to hide the quicklaunch menu.

<style type="text/css">
#sideNavBox {<br />
display: none;<br />
}<br />

But when you save the page layout, then load a page that uses this page layout in a browser you find that the left quick launch is still visible. Why?
Well, if you open the aspx file, in our case inline-page-layout.aspx in SPD (or Dreamweaver) you will see that within the PlaceHolderAdditionalPageHead Content Place Holder our inline style was converted to valid XML by SharePoint Design Manager and changed to:

<style type="text/css">
//<![CDATA[ #sideNavBox { display: none; } //]]><br />

Wow, that won’t work. Most browsers will see the CDATA block and ignore what is there, meaning that browsers will not process the included css. Well this one stumped me for a while, but I found a solution I like. Replace the entire original <style> tag in the HTML file with the following:

<style type="text/css">--><br />
<!-- #sideNavBox { display: none; --><br />
<!--ME: </style>-->

Save the HTML page layout and open the associated .aspx page. You should see:

<style type="text/css">
<!-- #sideNavBox { display: none; } --><br />

Perfect, that browsers can interpret. Nifty huh?
What we are doing is replacing the simple <style> tag with the new Design Manager Markup comment tagging. These Markup Start (MS) and Markup End (ME) tags allow us to pass any HTML/ tag directly to Design Manager without being converted to XML first. This allows us to send the inline styles to the associated .aspx untouched. I add the <!—and –> tags before and after the actual style properties only because in a HTML editor such as Dreamweaver, they will not see the <style> tag because it is in a Design Manager comment tag, so I want the editor to also ignore my inline style content. You actually do not need the <!—and –> if you plan to only work in a code view environment.
Have you found another solution to this problem? Please tell me.
See of all of my SharePoint 2013 Branding Tricks and Discoveries.

4 thoughts on “SharePoint 2013: Inline Styles in Design Manager Page Layout

  1. Panoone June 17, 2014

    Thank you! Lifesaving little tip.
    Knew there had to be a way to achieve such a stupidly simple need. 🙂

  2. Mike Rooker January 22, 2015

    You Sir are a scholar and gentleman.
    Thank you.
    NO one else seems to have had this gem/

  3. Patti December 14, 2015

    Great thanks!

  4. Jason May 16, 2017

    Every other post I can find wants you to do this through convoluted and complicated hacks, this is clean and simple!

Leave a Comment

Your email address will not be published. Required fields are marked *

Enter Code *

Filed Under


Do you need to build a custom search-driven component for your #digitalworkspace while saving thousands of hours of development time?

Join us on as we lift the hood of #PnP Modern Search v4, show you how it's built, & take you on a live coding adventure.

#Hybridwork is more than just a buzzword to latch onto; it’s the future for many organizations for the unforeseeable future. So, how can you use #Microsoft365 for #hybridwork? Let's breaks it down…

It's that time again! Join the #PixelMillWebinars on 4/29 where @EricOverfield lifts the hood of #PnP Modern Search v4, shows how it's built, & takes you on a live coding adventure to customizing your own web part using the power of the existing codebase.

What? Anchor links now work in #SharePoint site navigation! This fix snuck in and I completely missed it. Use them to create a TOC for long pages or cross link between pages. They work in text or quick links web parts & nav too!

A big thank you to David Leveille and @CrushNetworks for having our President + Co-Founder @EricOverfield on this episode of #TheVirtualWaterCooler!

Subscribe to PixelMill's

* indicates required

Let's Talk Digital
Workspaces Today

Get In Touch