<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: tommy george</title>
    <description>The latest articles on DEV Community by tommy george (@tommygeorge).</description>
    <link>https://dev.to/tommygeorge</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F261480%2Fd49f49f7-0c9f-42ea-96e3-4f66623f352f.jpg</url>
      <title>DEV Community: tommy george</title>
      <link>https://dev.to/tommygeorge</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tommygeorge"/>
    <language>en</language>
    <item>
      <title>No more self signed certificate warnings: HTTPS local development using Caddy 2 on macOS</title>
      <dc:creator>tommy george</dc:creator>
      <pubDate>Thu, 25 Jan 2024 00:59:00 +0000</pubDate>
      <link>https://dev.to/tommygeorge/no-more-self-signed-certificate-warnings-https-local-development-using-caddy-2-on-macos-13ac</link>
      <guid>https://dev.to/tommygeorge/no-more-self-signed-certificate-warnings-https-local-development-using-caddy-2-on-macos-13ac</guid>
      <description>&lt;p&gt;Cross posted from &lt;a href="https://www.tommygeorge.com/blog/https-local-dev-with-caddy-2-on-macos-ventura-without-self-signed-certificate-warnings/"&gt;my blog&lt;/a&gt; (from January 1). Hopefully useful in this wider community. =) &lt;/p&gt;




&lt;p&gt;Relatively recently, I saw &lt;a href="https://www.youtube.com/watch?v=7cBDFJ8cQhQ"&gt;Wes Bos' YouTube Short about local https with Caddy&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I tried exactly that, but kept getting the self-signed certificate warnings in browsers. Boo! I figured there must be an extra step on my machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;TL;DR&lt;/strong&gt;: This is how I got it working: Install &lt;code&gt;certutil&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Install `certutil`:
brew install nss
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;So, &lt;code&gt;brew install nss&lt;/code&gt;, and then &lt;code&gt;caddy file-server --domain tg.localhost&lt;/code&gt;, or even stuff like &lt;code&gt;caddy reverse-proxy --from tg.localhost --to http://localhost:1313&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The first time you run Caddy, it will prompt for your system password to install a trusted root cert. After that, no more "self signed certificate" warnings.&lt;/p&gt;

&lt;p&gt;And yes: Change &lt;code&gt;tg.localhost&lt;/code&gt; to just about anything you want. Open it in your browser, and it should "just work"!&lt;/p&gt;

&lt;h2&gt;
  
  
  How I figured it out
&lt;/h2&gt;

&lt;p&gt;When running things like &lt;code&gt;caddy file-server --domain tg.localhost&lt;/code&gt;, I noticed warnings in the output. This was while Caddy was trying to create/install the root certificate, and suggesting to install &lt;code&gt;certutil&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WARN    pki.ca.local    installing root certificate (you might be prompted for password)    {"path": "storage:pki/authorities/local/root.crt"}
INFO    warning: "certutil" is not available, install "certutil" with "brew install nss" and try again
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It &lt;em&gt;did&lt;/em&gt; prompt for local machine password a couple times, so I figured whatever fallback mechanism it was using would be working. But apparently not. Because I was still seeing "self signed" certificate warnings.&lt;/p&gt;

&lt;p&gt;I've never used &lt;code&gt;certutil&lt;/code&gt;, so wasn't familiar. But I decided to try it and ran &lt;code&gt;brew install nss&lt;/code&gt; per the recommendation from Caddy output.&lt;/p&gt;

&lt;p&gt;To be sure, I ran &lt;code&gt;caddy trust&lt;/code&gt;, (while &lt;code&gt;caddy run&lt;/code&gt; was running in another terminal!) and it worked flawlessly.&lt;/p&gt;

&lt;p&gt;In subsequent tests, I haven't had to untrust/trust. It "Just Works", as long as &lt;code&gt;certutil&lt;/code&gt; is already installed.&lt;/p&gt;

&lt;p&gt;Hope that's helpful!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>caddy</category>
      <category>https</category>
    </item>
    <item>
      <title>How to get the masked text effect from the Apple iPhone XR promo pages</title>
      <dc:creator>tommy george</dc:creator>
      <pubDate>Thu, 31 Oct 2019 19:02:38 +0000</pubDate>
      <link>https://dev.to/tommygeorge/how-to-get-the-masked-text-effect-from-the-apple-iphone-xr-promo-pages-9oe</link>
      <guid>https://dev.to/tommygeorge/how-to-get-the-masked-text-effect-from-the-apple-iphone-xr-promo-pages-9oe</guid>
      <description>&lt;p&gt;This is a repost of a fun thing I put &lt;a href="https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/"&gt;on my blog in 2018&lt;/a&gt;. I thought it would be fun to reformat a bit and share it here with the Dev community!&lt;/p&gt;




&lt;p&gt;I am a sucker for cool typography effects.&lt;/p&gt;

&lt;p&gt;As most "geeks", I was aware of Apple's &lt;a href="https://www.apple.com/apple-events/september-2018/"&gt;event this week&lt;/a&gt;, where they announced (among other stuff) some new iPhones.&lt;/p&gt;

&lt;p&gt;When checking out the promo website for the new iPhones, some of the text and design caught my eye. I couldn't remember immediately how it was done, so I thought it would be a fun opportunity to (re-) learn/visit a technique, and maybe write a little breakdown.&lt;/p&gt;

&lt;p&gt;And here we are!&lt;/p&gt;




&lt;h2&gt;
  
  
  The Effect
&lt;/h2&gt;

&lt;p&gt;There's a couple things I want to point out, but first, here's the effect in question, as it appears on the promo page for the &lt;a href="https://www.apple.com/iphone-xr/"&gt;iPhone XR&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DseABCnW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/apple-iphone-xr-promo-text-blue.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DseABCnW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/apple-iphone-xr-promo-text-blue.jpg" alt="" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's got:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cool textured/colored "masked" text. It's not an image!&lt;/li&gt;
&lt;li&gt;Some text that's &lt;em&gt;not&lt;/em&gt; masked, that appears to be in the same paragraph.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;If you wanna skip right to the code for the first example, &lt;a href="https://codepen.io/tommygeorge/pen/JaZxdJ"&gt;here's the CodePen&lt;/a&gt; where I first broke down the effect as they used it:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/tommygeorge/embed/JaZxdJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Figuring it out
&lt;/h2&gt;

&lt;p&gt;The first thing I did was pop open the Dev Tools and find out what was going on. For some reason, I was expecting something a bit more complicated, but I still want to break it down.&lt;/p&gt;

&lt;h3&gt;
  
  
  The innermost parts
&lt;/h3&gt;

&lt;p&gt;Inspecting the actual paragraph, I noticed that it's actually made of two things: an &lt;code&gt;h2&lt;/code&gt; (heading tag) followed by a regular paragraph (which is the text with the cool textured effect).&lt;/p&gt;

&lt;p&gt;This screenshot of the dev tools is a little noisy, but I highlighted the important parts that we'll talk about first...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DUInMiyx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/devtools-02.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DUInMiyx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/devtools-02.jpg" alt="" width="578" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Namely:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There's a containing &lt;code&gt;div&lt;/code&gt; with a couple of interesting class names: &lt;code&gt;masked-copy&lt;/code&gt;, and &lt;code&gt;texture-1&lt;/code&gt;. Both good clues.&lt;/li&gt;
&lt;li&gt;The heading tag has a class of &lt;code&gt;inline&lt;/code&gt;, which does exactly what you might think.&lt;/li&gt;
&lt;li&gt;The actual text paragraph.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The container and its' background
&lt;/h3&gt;

&lt;p&gt;That &lt;code&gt;texture-1&lt;/code&gt; class defines the color, and a particular "background image" that will be used for the paragraph(s) inside. I'm going to rename it for our examples, hopefully to make it a little more clear. It's defined something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.texture-orange&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url('path/to/texture-orange.jpg')&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those background images are actually some seriously bright, colorful, taller-than-they-are-wide, swirly, gradient texture images. Assuming they're still at the same URL, you can &lt;a href="https://www.apple.com/v/iphone-xr/a/images/overview/copy_texture_1_large.jpg"&gt;see one here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here's a very small example of the kind of thing going on in that background image:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9Uzlj1eE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/texture-orange-example.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9Uzlj1eE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/texture-orange-example.jpg" alt="" width="460" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, the container has a background image. We'll come back to that!&lt;/p&gt;

&lt;h3&gt;
  
  
  The text color "fallback"
&lt;/h3&gt;

&lt;p&gt;Next, I noticed that the paragraph had a color set by the &lt;code&gt;texture-1&lt;/code&gt; class -- something in the neighborhood of the background that would later be applied (in this case &lt;code&gt;#e5895f&lt;/code&gt; for the orange and purple texture/gradient). That color is overridden, however, by the &lt;code&gt;masked-copy&lt;/code&gt; rules, that specify a transparent "color" for the text. So far, we have some rules that look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.texture-orange&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#e5895f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url('path/to/texture-orange.jpg')&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.masked-copy&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;-webkit-background-clip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, I haven't taken a close enough look to determine their particular reason for using &lt;code&gt;!important&lt;/code&gt; on that color rule. I didn't notice any conflicting selectors. Also, it's not necessary for the example we'll build up. So you can ignore it in this case.&lt;/p&gt;

&lt;p&gt;The important (no pun intended) thing to note here is that they provided a solid color for the text, for browsers that don't support the &lt;code&gt;-webkit-background-clip: text&lt;/code&gt; rule...&lt;/p&gt;

&lt;h3&gt;
  
  
  background-clip, and &lt;code&gt;-webkit-background-clip&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This is where the magic happens!&lt;/p&gt;

&lt;p&gt;This may be a simplification, but this rule tells the container to hide all parts of the background (image or color) &lt;em&gt;except&lt;/em&gt; where the text is.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;background-clip&lt;/code&gt; property is &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/background-clip"&gt;defined on MDN&lt;/a&gt; like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The background-clip CSS property specifies if an element's background, whether a &amp;lt;color&amp;gt; or an &amp;lt;image&amp;gt;, extends underneath its border.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;... and when using the (experimental) &lt;code&gt;text&lt;/code&gt; value:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The background is painted within (clipped to) the foreground text.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Why the &lt;code&gt;-webkit-&lt;/code&gt; prefix?
&lt;/h3&gt;

&lt;p&gt;I'm definitely not the expert, and so far have only spent a little time looking this up. From what I could tell from the compatibility charts on MDN and "Can I Use...", the version of &lt;code&gt;background-clip&lt;/code&gt;, particularly with the &lt;code&gt;text&lt;/code&gt; value, has &lt;em&gt;better browser support&lt;/em&gt; when using the prefixed version. I could be wrong!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://caniuse.com/#feat=background-img-opts"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c24-g1sX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/caniuse.jpg" alt="" width="466" height="271"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;"Can I Use..." has this in the Note section for &lt;a href="https://caniuse.com/#feat=background-img-opts"&gt;CSS3 Background-image options&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Firefox, Chrome and Safari support the unofficial -webkit-background-clip: text (only with prefix)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As well, I've seen this work fine on Windows machines, in IE11 and Edge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building our own
&lt;/h2&gt;

&lt;p&gt;The final version of this is available in &lt;a href="https://codepen.io/tommygeorge/pen/JaZxdJ"&gt;this CodePen&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here's the step-by-step build up to the final result.&lt;/p&gt;

&lt;h3&gt;
  
  
  The minimum structure
&lt;/h3&gt;

&lt;p&gt;You only need a few things to pull this off:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a dark background&lt;/li&gt;
&lt;li&gt;a container with a background color or image&lt;/li&gt;
&lt;li&gt;a nice header (optional!?)&lt;/li&gt;
&lt;li&gt;and the paragraph that will look &lt;em&gt;awesome&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's the HTML we'll work with (excluding the body and all that cruft):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"masked-copy texture-orange big-type"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"inline"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Intelligent A12 Bionic.&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is the smartest, most powerful chip in a smartphone,
    with our next-generation Neural Engine. For amazing augmented reality
    experiences. Incredible portraits with Depth Control. And speed and
    fluidity in everything you do.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding CSS styles
&lt;/h3&gt;

&lt;p&gt;First, our dark background. We'll just make the &lt;code&gt;body&lt;/code&gt; element have a black background color:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make it look similar to Apple's design, we'll need some chunky/bold text.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.big-type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/*
  These rules were copied almost wholesale from the
  Apple site CSS; I changed the font-stack to be more
  generic
  */&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;64px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.0625&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* The height Apple used to tighten up the spacing a bit. */&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;600&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Nice, chunky, bold! */&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"Helvetica Neue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;"Helvetica"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;"Arial"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, rules to set the background image on our container, and set a solid color font that some older browsers will show, instead of the clipped background:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.texture-orange&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* Set the text color to a solid, in case our super cool effects don't work. */&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#e5895f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c"&gt;/*
  This is from the Apple styles.
  A word of caution: if your background image isn't at least as wide as
  your container, leave this off! Otherwise, it will hide text that
  falls outside of the background image.
  */&lt;/span&gt;
  &lt;span class="nl"&gt;background-repeat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c"&gt;/* You'll provide the URL to your texture background here. */&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url('/path/to/texture-orange.jpg')&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, it's probably looking something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZxFfM1VF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/001.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZxFfM1VF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/001.jpg" alt="" width="698" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As they did, let's make that header white. And while we're at it, notice one of my favorite touches in this design: semantically, there's a header and a paragraph. Visually, they pull the two together by changing the display property on the header and the paragraph elements from the default &lt;code&gt;block&lt;/code&gt; to &lt;code&gt;inline&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That change has to be applied to both elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.masked-copy&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inline&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.masked-copy&lt;/span&gt; &lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inline&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c"&gt;/* Get the font sizes and other features from those set on the parent */&lt;/span&gt;
  &lt;span class="nl"&gt;font&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without the background-clip and &lt;code&gt;color: transparent&lt;/code&gt; rules, you should see something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m2QrzcK1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/no-background-clip-and-no-transparent-text.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m2QrzcK1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/no-background-clip-and-no-transparent-text.jpg" alt="" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, adding &lt;code&gt;color: transparent&lt;/code&gt;, you'll see the paragraph disappear...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.masked-copy&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NTJEcCpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/no-background-clip-with-color-transparent.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NTJEcCpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/no-background-clip-with-color-transparent.jpg" alt="" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Finally&lt;/strong&gt;, &lt;em&gt;the star of the show&lt;/em&gt;, applying the &lt;code&gt;-webkit-background-clip: text&lt;/code&gt; rule will cause the &lt;em&gt;background image&lt;/em&gt; of the selected element to be "clipped", except for where the text exists, allowing the &lt;em&gt;background-color&lt;/em&gt; of the &lt;code&gt;body&lt;/code&gt; element (or another container) to show through:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.masked-copy&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;-webkit-background-clip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2nxT8_7W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/final-effect-on-texture-orange.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2nxT8_7W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/final-effect-on-texture-orange.jpg" alt="" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Final code
&lt;/h3&gt;

&lt;p&gt;All available in &lt;a href="https://codepen.io/tommygeorge/pen/JaZxdJ"&gt;this CodePen&lt;/a&gt;, and here for posterity:&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"masked-copy texture-orange big-type"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Intelligent A12 Bionic.&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is the smartest, most powerful chip in a smartphone, with our next-generation Neural Engine. For amazing augmented reality experiences. Incredible portraits with Depth Control. And speed and fluidity in everything you do.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  CSS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;900px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.big-type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/*
  These rules were copied almost verbatim from the
  Apple site CSS; I changed the font-stack to be more
  generic
  */&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;64px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.0625&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* The height Apple used to tighten up the spacing a bit. */&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;600&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Nice, chunky, bold! */&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"Helvetica Neue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;"Helvetica"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;"Arial"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.texture-orange&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* Set the text color to a solid, in case our super cool effects don't work. */&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#e5895f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c"&gt;/*
  The Apple stylesheet supplies a `background-repeat: no-repeat;` rule here.
  You can do the same, as long as your background image
  is at least as large as your text will be. Otherwise,
  text that falls outside of the background image will be
  invisible, and that's (usually) not what you want!
  */&lt;/span&gt;
  &lt;span class="c"&gt;/* background-repeat: no-repeat; */&lt;/span&gt;

  &lt;span class="c"&gt;/* You'll provide the URL to your texture background here. */&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url('/path/to/texture-orange.jpg')&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.masked-copy&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inline&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.masked-copy&lt;/span&gt; &lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inline&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c"&gt;/* Get the font sizes and other features from those set on the parent: */&lt;/span&gt;
  &lt;span class="nl"&gt;font&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.masked-copy&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* This is it! */&lt;/span&gt;
  &lt;span class="nl"&gt;-webkit-background-clip&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;Using a regular background image isn't the only way to go! You can just as easily do it in pure CSS by providing a gradient background. That would also eliminate any accidental text clipping oddities that might occur if you use &lt;code&gt;no-repeat&lt;/code&gt; backgrounds, etc.&lt;/p&gt;

&lt;p&gt;See the links in the references below for more examples using &lt;code&gt;background-clip&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Also, don't be afraid of the &lt;code&gt;-webkit&lt;/code&gt; prefix! This property has fantastic browser support, as mentioned before.&lt;/p&gt;

&lt;p&gt;And remember that "fallback" text color?&lt;/p&gt;

&lt;p&gt;Here's a shot of good ol' IE 9, on Windows Vista...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VBcCaJOA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/vista-ie-9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VBcCaJOA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.tommygeorge.com/blog/css-how-to-apple-iphone-xr-masked-text/vista-ie-9.jpg" alt="" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see the font in the "fallback" color, and no background. Not bad!&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;I am &lt;em&gt;so&lt;/em&gt; late to this party! This effect has been really well covered&lt;br&gt;
in a few other places, at least as early as &lt;em&gt;2013&lt;/em&gt;!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://nimbupani.com/using-background-clip-for-text-with-css-fallback.html"&gt;Divya Manian covered the effect&lt;/a&gt;, and alternatives, in fewer and better words than I could, back in 2013!&lt;/li&gt;
&lt;li&gt;Of course, CSS Tricks has &lt;a href="https://css-tricks.com/how-to-do-knockout-text/"&gt;"How To Do Knockout Text"&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color"&gt;MDN CSS docs on &lt;code&gt;color&lt;/code&gt;&lt;/a&gt;, because &lt;code&gt;transparent&lt;/code&gt; is apparently an option.&lt;/li&gt;
&lt;li&gt;Can I use... &lt;a href="https://caniuse.com/#feat=background-img-opts"&gt;CSS3 Background-image options&lt;/a&gt;. Browser support is pretty great!&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://codepen.io/tommygeorge/pen/JaZxdJ?editors=1100"&gt;The CodePen I made to accompany this post&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>css</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
