<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - em-based media queries in <source> are relative to <html> instead of browser default font"
href="https://bugs.webkit.org/show_bug.cgi?id=159635">159635</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>em-based media queries in <source> are relative to <html> instead of browser default font
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>Safari 9
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>OS X 10.11
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>HTML DOM
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mattwondra@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>cdumez@apple.com
</td>
</tr></table>
<p>
<div>
<pre>On Safari 9.1, when I use em-based media queries in <source>s inside a <picture> element, the em units are relative to the <html> element's font size. This is different from the CSS @media rule, where em-based queries are relative to the browser's default font.
I have a reduced test case here: <a href="http://codepen.io/mattwondra/pen/jAaNvj">http://codepen.io/mattwondra/pen/jAaNvj</a>
Given the following code and standard 16px browser default font size, I expect the image to switch when I cross 800px browser width (50em * 16px = 800). Instead, it switches when I cross 600px because the <html> element has been give a font-size of 12px (50em * 12px = 600).
<style>
html { font-size: 12px; }
</style>
<picture>
<source srcset="large.jpg" media="(min-width: 50em)" />
<img src="small.jpg" alt="" />
</picture>
Is this expected behavior? Thanks for your time!</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>