Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 5960)
+++ /CKEditor/trunk/CHANGES.html	(revision 5961)
@@ -73,4 +73,5 @@
 		<li><a href="http://dev.ckeditor.com/ticket/5045">#5045</a> : uiColor behaved wrong if multiple editors were used with period in their names.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/5766">#5766</a> : Config entry "ignoreEmptyParagraph" should only remove one single empty paragraph in document.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/5931">#5931</a> : Unable to apply inline style because of nested elements with same style name.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.ckeditor.com/ticket/6427">#6427</a> : Ukrainian;</li>
Index: /CKEditor/trunk/_source/plugins/styles/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/styles/plugin.js	(revision 5960)
+++ /CKEditor/trunk/_source/plugins/styles/plugin.js	(revision 5961)
@@ -479,8 +479,20 @@
 			{
 				// Build the style element, based on the style object definition.
-				var styleNode = getElement( this, document );
+				var styleNode = getElement( this, document ),
+					styleHasAttrs = styleNode.hasAttributes();
 
 				// Get the element that holds the entire range.
 				var parent = styleRange.getCommonAncestor();
+
+				var removeList = {
+					styles : {},
+					attrs : {},
+					// Styles cannot be removed.
+					blockedStyles : {},
+					// Attrs cannot be removed.
+					blockedAttrs : {}
+				};
+
+				var attName, styleName, value;
 
 				// Loop through the parents, removing the redundant attributes
@@ -490,20 +502,24 @@
 					if ( parent.getName() == elementName )
 					{
-						for ( var attName in def.attributes )
+						for ( attName in def.attributes )
 						{
-							if ( styleNode.getAttribute( attName ) == parent.getAttribute( attName ) )
-								styleNode.removeAttribute( attName );
+							if ( removeList.blockedAttrs[ attName ] || !( value = parent.getAttribute( styleName ) ) )
+								continue;
+
+							if ( styleNode.getAttribute( attName ) == value )
+								removeList.attrs[ attName ] = 1;
+							else
+								removeList.blockedAttrs[ attName ] = 1;
 						}
 
-						for ( var styleName in def.styles )
+						for ( styleName in def.styles )
 						{
-							if ( styleNode.getStyle( styleName ) == parent.getStyle( styleName ) )
-								styleNode.removeStyle( styleName );
-						}
-
-						if ( !styleNode.hasAttributes() )
-						{
-							styleNode = null;
-							break;
+							if ( removeList.blockedStyles[ styleName ] || !( value = parent.getStyle( styleName ) ) )
+								continue;
+
+							if ( styleNode.getStyle( styleName ) == value )
+								removeList.styles[ styleName ] = 1;
+							else
+								removeList.blockedStyles[ styleName ] = 1;
 						}
 					}
@@ -511,4 +527,13 @@
 					parent = parent.getParent();
 				}
+
+				for ( attName in removeList.attrs )
+					styleNode.removeAttribute( attName );
+
+				for ( styleName in removeList.styles )
+					styleNode.removeStyle( styleName );
+
+				if ( styleHasAttrs && !styleNode.hasAttributes() )
+					styleNode = null;
 
 				if ( styleNode )
@@ -536,4 +561,13 @@
 					if ( !CKEDITOR.env.ie )
 						styleNode.$.normalize();
+				}
+				// Style already inherit from parents, left just to clear up any internal overrides. (#5931)
+				else
+				{
+					styleNode = new CKEDITOR.dom.element( 'span' );
+					styleRange.extractContents().appendTo( styleNode );
+					styleRange.insertNode( styleNode );
+					removeFromInsideElement( this, styleNode );
+					styleNode.remove( true );
 				}
 
