Skip to content

SharePoint Designer Modifies HTML On Save

The “Designer” in SharePoint Designer is used a little too liberally I think, but regardless here are two issues that SharePoint Designer does to your markup when saving the file. As far as I know this issue happens in both the 2007 and 2010 versions. Also, despite looking through all the program’s options, I can’t find one that causes this behavior to turn it off.

Designer Removes Closing HTML Tags

The first is that it removes closing HTML tags. This happens when you use the shorthand to close a SharePoint control. Here is what it looks like when this issue comes up.

<p>
<SharePointWebControls:fieldvalue id="BoxFourContent" FieldName="BoxFourContent" 
     runat="server"/>
</p>

When saving the file (in this case a page layout), SharePoint Designer removes the closing paragraph tag. To change this instead of using the shorthand to self-close the SharePoint control use the longer version.

<p>
<SharePointWebControls:fieldvalue id="BoxFourContent" FieldName="BoxFourContent" 
     runat="server"></SharePointWebControls:fieldvalue>
</p>

Designer Adds a Non-Breaking Space Character

The second issue is SharePoint Designer adding a non-breaking space character when saving. Here is the markup that causes the issue.

<h2>
<SharePointWebControls:fieldvalue id="PageTitle" FieldName="Title" runat="server"/>
</h2>

In this case simply wrap the control in a span, and the issue goes away. Notice I am using a self-closing tag, yet for some reason in this instance (in the very same document) it doesn’t remove the closing HTML tag. Perplexing.

<h2><span>
<SharePointWebControls:fieldvalue id="PageTitle" FieldName="Title" runat="server"/>
</span></h2>

The first rule of a good web design tool: don’t mess with my markup.

8 Comments

  1. David Followes

    I’ve noticed that it removes …. tags on saving e.g.

    ” ”
    ” ”
    ” A”
    ” ”
    ” B”

    becomes:

    ” ”

    A
    ” ”
    B

    I have no answer for this but would like one!

    • Hey David – I can’t quite tell what the issue is.

  2. David Followes

    Sorry about the last reply, it should have said

    I’ve noticed that it removes .… tags on saving e.g.
    <div id=”radio”>
    <input type=”radio” id=”radio1″ name=”radio” checked=”checked”/>
    <label for=”radio1″>A</label>
    <input type=”radio” id=”radio2″ name=”radio”/>
    <label for=”radio2″>B</label>
    <input type=”radio” id=”radio3″ name=”>
    <label for=”radio3″>C</label>
    ….

    Gets reduced to

    <div id=”radio”>
    <input type=”radio” id=”radio1″ name=”radio” checked=”checked”/>
    A
    <input type=”radio” id=”radio2″ name=”radio”/>
    B
    <input type=”radio” id=”radio3″ name=”>
    C
    ….

    I have no answer for this but would like one!

    • Not sure. I just looked in SharePoint Designer 2010 options because I thought there was an option for automatically correcting invalid XHTML. I didn’t see one however.

  3. xr280xr

    Ya, SharePoint Designer 2007 is an unfinished, POS.

  4. John Cross

    I think I have found a solution for the closing tag issue. Don’t use short form tags (ie ending with a /), instead open and close the tag.

    So, with the following I found that the closing h1 tag was removed:
    >h1<>SharePointWebControls:TextField FieldName=”Title” runat=”server”/<>/h1<

    but when I changed it to this the closing tag was not removed:
    >h1<>SharePointWebControls:TextField FieldName=”Title” runat=”server”<>/SharePointWebControls:TextField<>/h1<

Leave a Reply

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