I am editing the following master page which my current SharePoint site is using (I am using SharePoint 2007 + Windows Server 2008),


Currently, I am using the hard-coded value "120" to set the width of the left navigation bar, here is the related code in the master file. How do I set the width of left navigation bar to be automatically changed according to the max length of items on left navigration bar?

<SharePoint:AspMenu ID="CurrentNav" width="120" runat="server" datasourceID="SiteMapDS" orientation="Vertical" StaticDisplayLevels="2" MaximumDynamicDisplayLevels="0" StaticSubMenuIndent="1" ItemWrap="true" AccessKey="3" CssClass="leftNav" SkipLinkText="<%$Resources:cms,masterpages_skiplinktext%>">

1 Answer 1


You might want to do this with jQuery on the client side. The trick will be to determine the number of pixels wide required per character given your font family and size choice. Depending on how you are setting your font sizes, you may be able to take advantage of ems, but that would assume that characters are on average as wide as they are tall, which may not be the case with the font family you have chosen.


  • Marc, thanks! jQuery is new to me, any related reference samples?
    – George2
    Nov 8, 2009 at 18:16
  • I don't think I have a jQuery example, but here's a sort of related example in which I dynamically set the width of multi-select boxes on a form with JavaScript: mdasblog.wordpress.com/2008/12/30/… The logic would be similar, but the jQuery would be simpler. M. Nov 9, 2009 at 19:53

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.