2

I've noticed that SharePoint 2010 wraps rich text fields (multiline text) with DIV tags, which can be annoying. I've got a custom XSL template for the columns being pulled by a content query web part and would like to format the text correctly; unfortunately, the extra "naked" DIV tags (no attributes) cause line breaks where I don't need them.

For example, the following has a line break:

Address: <xsl:value-of select="@MyAddressColumn" disable-output-escaping="yes"/>

So it comes out like this:

Address: 
123 Main St.

I want it to be this instead:

Address: 123 Main St.

Is there any way to prevent these DIV tags from being generated around the content by SharePoint? Thanks.

1 Answer 1

3

One way to fix this was to append a class on a tag surrounding the address, and then add display:inline to the nested DIV:

.test div
{
    Display:inline;
}


<DIV class="test">address: <DIV>123 main st.</DIV></DIV>
2
  • Thanks, Anders. This doesn't get to the bottom of the issue, though. And it will add the style to all descendent DIVs, which might not be exactly what we want. I've tried using jQuery/CSS to fix it, but would like to know where the DIV is generated and if it's possible to modify that code.
    – Alex C
    Aug 14, 2011 at 10:17
  • 2
    The DIV tag is generated in the RenderControl for either InputFormTextBox or one of its parent controls. If you want to remove those DIV's you could create a control adapter for it, but it seems like a lot of hazle for something that can be solved by one line of CSS :-) blog.mastykarz.nl/inconvenient-control-adapters Aug 14, 2011 at 10:28

Your Answer

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

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