<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tony Montemorano on Medium]]></title>
        <description><![CDATA[Stories by Tony Montemorano on Medium]]></description>
        <link>https://medium.com/@allusis?source=rss-6ca04fb6ce4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dS5dMnKMP6ePLbHemUW_rQ.jpeg</url>
            <title>Stories by Tony Montemorano on Medium</title>
            <link>https://medium.com/@allusis?source=rss-6ca04fb6ce4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 03:09:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@allusis/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Our HTML friend named picture]]></title>
            <link>https://allusis.medium.com/our-html-friend-named-picture-a8cf755a3332?source=rss-6ca04fb6ce4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8cf755a3332</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ux]]></category>
            <dc:creator><![CDATA[Tony Montemorano]]></dc:creator>
            <pubDate>Wed, 06 Mar 2019 22:00:30 GMT</pubDate>
            <atom:updated>2024-11-28T02:19:28.124Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7bo2Da9nPGknpF-zcRA8w.jpeg" /></figure><h3>Meet Your New HTML BFF: &lt;picture&gt;</h3><p>Photos are the unsung heroes of web design — they’re vibrant, attention-grabbing, and, let’s face it, downright essential. If they’re not pulling their weight in your design, they shouldn’t be there in the first place.</p><p>Now, when we say “photos,” we mean actual photographs: images snapped with a camera or crafted as bitmaps (think JPGs, PNGs, etc.). In responsive design, we usually resize these images to fit various screen sizes. But let’s be real — this often leads to a disappointing quality gap.</p><p>Enter the &lt;picture&gt; element: your new ally in enabling multiple image sources to deliver crisp, high-quality images tailored to your users’ specific conditions, like their screen resolution or network speed.</p><h3>Why Multiple Image Sources?</h3><p>Not every image needs a buffet of sources, but there are some situations where they make a huge difference. Let’s explore a couple of scenarios.</p><p><strong>1. Hero Images:</strong><br>Hero images are the show-stoppers — often full-width and central to your design. But what looks stunning on a desktop screen can turn into a postage stamp on mobile, leaving your users squinting to figure out what’s going on.</p><p><strong>The Fix:</strong> Serve up different images for different devices! By using a more mobile-friendly aspect ratio, you can keep your hero image heroic everywhere.</p><p><strong>2. High-Resolution Displays:</strong><br>Screens are getting sharper by the second, with retina displays and high-pixel-density devices becoming the norm. If you’re rocking a gorgeous photo, showing it off at low resolution just won’t cut it — it’s pixelated heartbreak waiting to happen.</p><p><strong>The Fix:</strong> Multiple sources save the day again. You can deliver lower-res images for smaller screens to save bandwidth and reserve those ultra-HD versions for devices that can truly do them justice.</p><h3>How to Use the &lt;picture&gt; Element</h3><p>Here’s a practical example:</p><pre>&lt;picture&gt;<br>  &lt;source media=&quot;(min-width:64rem)&quot; srcset=&quot;img/sudden-valley.jpg&quot;&gt;<br>  &lt;source srcset=&quot;img/sudden-valley_sm.jpg&quot;&gt;<br>  &lt;img src=&quot;img/sudden-valley.jpg&quot;/&gt;<br>&lt;/picture&gt;</pre><p><strong>What’s happening here?</strong></p><ol><li>&lt;picture&gt; is the container for all the magic.</li><li>&lt;source&gt; defines the images you’d like to serve based on conditions (like screen width).</li><li>&lt;img&gt; is your trusty fallback—ready to shine if the browser doesn’t support &lt;picture&gt;.</li></ol><h3>Key Ingredients: &lt;source&gt; and Its Attributes</h3><p>The &lt;source&gt; element is the powerhouse of the &lt;picture&gt; tag. Each &lt;source&gt; represents a specific image that can be conditionally loaded based on user needs. Want to use a dozen sources? Go for it—though two or three usually do the trick.</p><p>Here’s the breakdown of common attributes:</p><ul><li><strong>media</strong>: Use media queries to specify when this source should apply.</li><li><strong>srcset</strong>: Define the path to the image and its intended size.</li><li><strong>type</strong>: Set the MIME type (e.g., JPEG or WebP); browsers skip it if unsupported.</li></ul><pre>&lt;picture&gt;<br>  &lt;source media=&quot;(min-width: 72rem)&quot; srcset=&quot;img/sudden-valley_16x9-lg.jpg&quot;&gt;<br>  &lt;source media=&quot;(min-width: 64rem)&quot; srcset=&quot;img/sudden-valley_16x9.jpg&quot;&gt;<br>  &lt;source srcset=&quot;img/sudden-valley_9x9.jpg&quot;&gt;<br>  &lt;img src=&quot;img/sudden-valley_16x9.jpg&quot;/&gt;<br>&lt;/picture&gt;</pre><h3>Support &amp; Considerations</h3><p>While &lt;picture&gt; is fully valid HTML5, not all browsers are 100% on board yet. Thankfully, that’s where your fallback &lt;img&gt; steps in. If the browser doesn’t support &lt;picture&gt;, the &lt;img&gt; tag ensures no one misses out.</p><h3>Go Forth and Prosper!</h3><p>The &lt;picture&gt; element is your ticket to beautifully responsive images. But remember, this isn’t a hall pass to load your site with 800KB behemoths. Use it wisely to serve the right image to the right device—and keep your users smiling, no matter their screen size.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8cf755a3332" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SVG sprites]]></title>
            <link>https://allusis.medium.com/svg-sprites-562730aa7a1?source=rss-6ca04fb6ce4------2</link>
            <guid isPermaLink="false">https://medium.com/p/562730aa7a1</guid>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[image-sprite]]></category>
            <dc:creator><![CDATA[Tony Montemorano]]></dc:creator>
            <pubDate>Fri, 09 Feb 2018 21:19:46 GMT</pubDate>
            <atom:updated>2019-03-06T21:52:35.655Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Last updated: 3/6/19</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N3fzUdlzb_h-bOhCHQgVkQ.png" /></figure><h3>Introduction</h3><p>An image sprite, defined loosely, is just a single image that contains other images.</p><p>Sprites even in a bitmap format (e.g., .jpg, .png), can save a huge amount of time, and will really up your icon-game. More importantly it will prevent a whole bunch of annoying individually loaded resources from being loaded on your pages.</p><p>When it comes to bitmap images however, supporting high-pixel density displays (i.e., mobile/retina screens) means that you need a separate, larger image at least twice the resolution to prevent the icon’s from pixelating.</p><p>When you don’t create higher resolution images, you’ll see junky or pixelated images. It’s sad looking, but there’s hope, and it’s called SVG (Scaleable Vector Graphics).</p><p>With SVGs, we don’t have to worry about creating separate images. Yep, one size fits all. That means, when you pick up a 20k iPhone screen in a few years, your icons will still be just as crispy.</p><p>In this post we’ll review some important considerations, and illustrate some ways to implement a scaleable SVG sprite design/development process that could save you a metric ton of frustration — and give you crispy icons everywhere.</p><h3>The Basic’s</h3><p>Just like any SVG, you can open a sprite up in your favorite text editor and see your image’s shapes in XML-based code.</p><p>The structure of an SVG sprite is slightly different than a single SVG image. For each icon in a sprite a &lt;symbol&gt; should be added as children to &lt;defs&gt;. Each symbol has it&#39;s own viewBox and id attributes.</p><p><strong>The basic structure of a svg sprite image:</strong></p><pre>&lt;svg version=&quot;1.1&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;<br>  &lt;defs&gt;</pre><pre>    &lt;symbol id=&quot;caret&quot; viewBox=&quot;0 0 16 16&quot;&gt;<br>      &lt;polygon points=&quot;3,5 8,11 13,5&quot; /&gt;<br>    &lt;/symbol&gt;</pre><pre>  &lt;/defs&gt;<br>&lt;/svg&gt;</pre><p>This sprite can be its own separate file, or it can be placed right at the top of the page it’s used on. If used on the page, you’d want to hide the sprite from rendering with a display:none or something similar.</p><h3>SVG Sprite Considerations</h3><p>There are a few important points to think through when using SVG’s in general, and the same goes for an SVG sprite. The approach someone should take to building a sprite may depend upon some of the considerations below:</p><h4>Support</h4><ul><li>Svg sprites as an external source won’t work in IE 9, 10, 11 without a polyfill. This means loading them from your images folder is a no-go. See <a href="https://jonathantneal.github.io/svg4everybody/">SVG for Everybody</a>.</li><li>Native mobile apps still appear to prefer bitmap images.</li></ul><h4>The Domain</h4><p>Sprite images need to be served from the same domain thats serving the actual page in order to work. If this isn’t possible there are still some (less desirable) options.</p><ul><li>Use the svg’s inline</li><li>Add the sprite to the page/component(s) it’s used on</li><li>Use individual &lt;img&gt; tag&#39;s for every icon</li></ul><blockquote><strong><em>Note:</em></strong><em> </em>Adding svgs/sprites inline is going to create more markup that needs to be rendered every time the page loads. This could affect your pages loading time a bit more than loading a single sprite image once (with an external image) would.</blockquote><h4>Icon Sizing</h4><p>Keeping icon and viewBox sizes consistent for each icon is going to save a lot of time, especially with sprites. If you aren’t familiar with these attributes already, you can read up on them in this article: <a href="https://css-tricks.com/scale-svg/">How to Scale SVG</a></p><h4>Color Manipulation</h4><p>Manipulating SVG’s with CSS is easily one of the coolest features. But there are some limitations to be aware of:</p><ul><li>Referencing SVGs with `&lt;img&gt;` tag’s means they _can’t_ be manipulated with CSS.</li><li>When using SVGs inline, the paths can be manipulated individually. Keep in mind it means adding markup that will have to be loaded every time the icon is used.</li><li>When using external sprites the fills or strokes can be manipulated with CSS, but it’s an all or nothing scenario. For example, setting a fill color will set the fill for every shape that doesn’t have a fixed fill even if you try to target ID’s or Classes. (More on that later.)</li></ul><h3>Putting a sprite into action</h3><h4>Image setup</h4><p>Since you can’t manipulate colors for shapes that have existing fills or strokes on them, you’ll want to remove both for every shape or group that you would want to change with CSS.</p><p>This is a good time to remove any junk comments, or empty `&lt;g&gt;` (group) tag’s if they exist. Just be sure you know what you’re removing!</p><p><strong>Before removal (note the fill):</strong></p><pre>&lt;symbol id=”caret-down” viewBox=”0 0 16 16&quot; &gt;<br> &lt;polygon points=”3,5 8,11 13,5&quot; fill=”#333333” /&gt;<br>&lt;/symbol&gt;</pre><p><strong>After removal:</strong></p><pre>&lt;symbol id=”caret-down” viewBox=”0 0 16 16&quot; &gt;<br> &lt;polygon points=”3,5 8,11 13,5&quot; /&gt;<br>&lt;/symbol&gt;</pre><blockquote><strong><em>Note:</em></strong><em> </em>If you have an icon with multiple shapes, and you only want to manipulate some, you can keep fixed fills (or strokes) on the elements that shouldn’t change. Keep in mind, no matter how much CSS you throw at them, they will not change if they have a fixed color.</blockquote><h4>Consistent icon sizes</h4><p><strong>See an example of mismatched icons below:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/0*vvmuBe032MDfn0gO.jpg" /></figure><p>The Codepen icon is a bit smaller than the Github icon. This isn’t an extreme difference, but if we saw these next to each other, we’d certainly notice it.</p><p><strong>There are a couple things we can do to make sure they render consistently:</strong></p><ol><li>First and foremost, try to use icons from the same source to keep them as consistent as possible. (<a href="https://nucleoapp.com/?ref=93">Nucleo</a> is amazing for this).</li><li>If you can’t do that, throw them all in a Sketch file to be used as a working icon sprite source file. Use separate art boards or symbols for each icon and turn on the grid or create rulers to line them up and resize them. Export individually in the .svg format and copy and paste them into your sprite.</li></ol><blockquote><strong><em>Note:</em></strong><em> </em>Most design tools will load the file with comments, and junk code. Sketch is no different, but most of the time you’ll find that the grouping does for the output file does match the grouping of the elements in your artboard very closely.</blockquote><h4>Manipulating sprite icon colors with CSS</h4><p>After removing the fill or stroke from an icon, the defined shapes will be black by default. Gross! Chances are that’s not what you’re going for. Here is where the magic happens:</p><p><strong>Setting a specific color:</strong></p><pre>.my-icon {<br>  fill: rebeccapurple<br>}</pre><p><strong>Setting a dynamic color:</strong></p><pre>.my-icon {<br>  fill: currentColor<br>}</pre><p>The currentColor value is the inherited color value (from its parents). This is great for auto-magically changing icon colors without writing extra CSS.</p><blockquote><strong><em>Note:</em></strong><em> </em>Despite possibly being the only value that uses camel-case, currentColor is a plain old CSS. It can be used with other properties that use color values.<em> </em>Read more about <a href="https://css-tricks.com/currentcolor">currentColor on CSS-Tricks</a><em>.</em></blockquote><p>I find it helpful to create two utility classes for my icons sprites. .icon-fill for icons that have fill’s i’d like to manipulate, and .icon-stroke for the stroke-based icons.</p><pre>.icon-fill {<br>  fill: currentColor<br>}</pre><pre>.icon-stroke {<br>  stroke: currentColor<br>}</pre><p>Applying this class to my icon references ensures that I never have to worry about the icon not matching the text color. I’ve found that this easily covers 90 percent of the my cases.</p><h3>Adding icons to a page</h3><p>Basic SVG reference in markup</p><pre>&lt;svg class=&quot;icon-fill&quot;&gt;<br>  &lt;use xlink:href=&quot;img/sprite_base.svg#caret-down&quot;&gt;&lt;/use&gt;<br>&lt;/svg&gt;</pre><p>If the image exists on the page your referencing them on you can omit the file path and just use #iconName</p><h3>Break a leg</h3><p>We hope you never bitmap image again for an icon! Check out a sample of the code to play around a bit:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fallusis%2Fembed%2Fpreview%2FOQRrGW%3Fheight%3D600%26slug-hash%3DOQRrGW%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fallusis%2Fpen%2FOQRrGW&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F5102.OQRrGW.small.e45d0a9e-d3c6-464b-8c3c-7efe41423f66.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ff93edcfcdf9943e2c4dc91c7fafb66/href">https://medium.com/media/4ff93edcfcdf9943e2c4dc91c7fafb66/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=562730aa7a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>