How to wrap menu items in SharePoint 2013 global navigation?

This is a quick post to show the code snippet I used to wrap the global navigation items in SharePoint 2013. You can also use custom CSS code in order to get some space between navigation lines and items. First, open default masterpage of your site collection and find the following:

<SharePoint:AspMenu
   ID="TopNavigationMenu"
   Runat="server"
   EnableViewState="false"
   DataSourceID="topSiteMap"
   AccessKey="<%$Resources:wss,navigation_accesskey%>"
   UseSimpleRendering="true"
   UseSeparateCss="false"
   Orientation="Horizontal"
   StaticDisplayLevels="2"
   AdjustForShowStartingNode="true"
   MaximumDynamicDisplayLevels="2"
   SkipLinkText="" />

and replace with the code below:

<SharePoint:AspMenu
   ID="TopNavigationMenu"
   Runat="server"
   EnableViewState="false"
   DataSourceID="topSiteMap"
   AccessKey="<%$Resources:wss,navigation_accesskey%>"
   UseSimpleRendering="false"
   UseSeparateCss="false"
   Orientation="Horizontal"
   StaticDisplayLevels="2"
   AdjustForShowStartingNode="true"
   MaximumDynamicDisplayLevels="2"
   SkipLinkText=""
   ItemWrap="true"
   RenderingMode="List" 
   cssClass="mycss"/>

As you can see, the only diference is:

ItemWrap="true"
RenderingMode="List"
cssClass="mycss"

Create custom CSS file with the following content:

.mycss .level1
{
margin-left: 10px;
margin-right: 20px;
}
.mycss .level2
{
margin-left: 10px;
margin-right: 20px;
}
.mycss .level3
{
margin-left: 10px;
margin-right: 20px;
}

SharePoint branding with custom CSS?

The custom CSS filelets you apply custom CSS to a SP content. Be aware that option is available only within a SharePoint server publishing site. The custom CSS option also ensures that this CSS file will load last, which prevents the Corev4.css from overriding it.

Here are some useful css tricks:

<style type="text/css">
/* Change ribbon background color */
body #s4-Ribbonrow {
    background-color:#283A10;
} 
</style>
<style type="text/css">
/* Change header */
.s4-title {
height:125px;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#C3D6AA',     endColorstr='#283A10'); /* for IE */
background: -moz-linear-gradient(top, #C3D6AA, #283A10); /* for firefox 3.6+ */
}
</style>
<style type="text/css">
/* Change the breadcrumb in the title area */
.s4-title h1 a {
color:#1E4620;
font-variant:small-caps;
font-weight:bold;
}</style>
<style type="text/css">
/* Change the color of the page title in the header area */
.s4-title h2 a {
color:#383838;
}
/* Team Site*/
.ms-WikiPageNameEditor-Display {
color:#383838;
}
/*Blog Site*/   
.s4-titletext h2 {
color:#383838;
}
</style>