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


Are you preparing to launch a new #SharePoint #intranet?

Don’t spring it on employees out of the blue. First, talk to as many of them as you can.

Planning is just phase one. For all of our tips, watch our recent webinar with @EricOverfield!

Are you preparing to launch a new #SharePoint intranet?

Don’t spring it on employees out of the blue. First, talk to as many of them as you can.

Planning is just phase one. For all of our tips, watch our recent webinar!

It's that time again! Join #Microsoft MVP & Regional Director, @EricOverfield on Thursday, October 28th, at 11:00 AM PST as he walks through #MicrosoftViva’s current state & offerings and what they mean to your #digitalworkspace right now.

It's the final countdown! Join @EricOverfield at 11am PST to learn about common pitfalls and paths to success when moving to #SharePointOnline. You'll walk away with practical tips to use in your organization today!

In today's episode of the #PixelMillWebinars, you'll learn from the experience of a global organization’s path to digital teamwork victory and get to see first-hand how to successfully plan a smooth migration for your team.

Join us at 11am PST!

Subscribe to PixelMill's

* indicates required

Let's Talk Digital
Workspaces Today

Get In Touch