Index: tests/Zend/View/Helper/HeadLinkTest.php
===================================================================
--- tests/Zend/View/Helper/HeadLinkTest.php	(revision 18530)
+++ tests/Zend/View/Helper/HeadLinkTest.php	(working copy)
@@ -444,6 +444,13 @@
         $this->assertContains(' media="screen,print"', $test);
     }
 
+    public function testSetStylesheetWithMediaAsCommaSeparatedString()
+    {
+        $this->helper->appendStylesheet('/bar/baz', 'screen, print');
+        $test = $this->helper->toString();
+        $this->assertContains(' media="screen, print"', $test);
+    }
+
     /**
      * @issue ZF-5435
      */
Index: tests/Zend/View/Helper/HeadStyleTest.php
===================================================================
--- tests/Zend/View/Helper/HeadStyleTest.php	(revision 18530)
+++ tests/Zend/View/Helper/HeadStyleTest.php	(working copy)
@@ -401,6 +401,22 @@
 
     }
 
+    public function testMediaAttributeCanHaveSpaceInCommaSeparatedString()
+    {
+        $this->helper->setIndent(4);
+        $this->helper->appendStyle('
+a {
+    display: none;
+}', array('media' => 'screen, projection'));
+        $string = $this->helper->toString();
+
+        $scripts = substr_count($string, '    <style');
+        $this->assertEquals(1, $scripts);
+        $this->assertContains('    <!--', $string);
+        $this->assertContains('    a {', $string);
+        $this->assertContains(' media="screen,projection"', $string);
+    }
+
     public function testConditionalScript()
     {
         $this->helper->appendStyle('
Index: library/Zend/View/Helper/HeadStyle.php
===================================================================
--- library/Zend/View/Helper/HeadStyle.php	(revision 18530)
+++ library/Zend/View/Helper/HeadStyle.php	(working copy)
@@ -324,6 +324,7 @@
                         $media_types = explode(',', $value);
                         $value = '';
                         foreach($media_types as $type) {
+                            $type = trim($type);
                             if (!in_array($type, $this->_mediaTypes)) {
                                 continue;
                             }

