lea.verou.me/2021/06/inherit-ancestor-font-size-for-fun-and-profit

Preview meta tags from the lea.verou.me website.

Linked Hostnames

17

Search Engine Appearance

Google

https://lea.verou.me/2021/06/inherit-ancestor-font-size-for-fun-and-profit

Inherit ancestor font-size, for fun and profit • Lea Verou

If you’ve been writing CSS for any length of time, you’re probably familiar with the em unit, and possibly the other type-relative units. We are going to refer to em for the rest of this post, but anything described works for all type-relative units. As you well know, em resolves to the current font size on all properties except font-size, where it resolves to the parent font size. It can be quite useful for making scalable components that adapt to their context size. However, I have often come across cases where you actually need to “circumvent” one level of this. Either you need to set font-size to the grandparent font size instead of the parent one, or you need to set other properties to the parent font size, not the current one. If you’re already familiar with the problem and just want the solution, skip ahead. The next few paragraphs are for those thinking “but when would you ever need this?” Sometimes, there are workarounds, and it’s just a matter of keeping DRY. For example, take a look at this speech bubble:



Bing

Inherit ancestor font-size, for fun and profit • Lea Verou

https://lea.verou.me/2021/06/inherit-ancestor-font-size-for-fun-and-profit

If you’ve been writing CSS for any length of time, you’re probably familiar with the em unit, and possibly the other type-relative units. We are going to refer to em for the rest of this post, but anything described works for all type-relative units. As you well know, em resolves to the current font size on all properties except font-size, where it resolves to the parent font size. It can be quite useful for making scalable components that adapt to their context size. However, I have often come across cases where you actually need to “circumvent” one level of this. Either you need to set font-size to the grandparent font size instead of the parent one, or you need to set other properties to the parent font size, not the current one. If you’re already familiar with the problem and just want the solution, skip ahead. The next few paragraphs are for those thinking “but when would you ever need this?” Sometimes, there are workarounds, and it’s just a matter of keeping DRY. For example, take a look at this speech bubble:



DuckDuckGo

https://lea.verou.me/2021/06/inherit-ancestor-font-size-for-fun-and-profit

Inherit ancestor font-size, for fun and profit • Lea Verou

If you’ve been writing CSS for any length of time, you’re probably familiar with the em unit, and possibly the other type-relative units. We are going to refer to em for the rest of this post, but anything described works for all type-relative units. As you well know, em resolves to the current font size on all properties except font-size, where it resolves to the parent font size. It can be quite useful for making scalable components that adapt to their context size. However, I have often come across cases where you actually need to “circumvent” one level of this. Either you need to set font-size to the grandparent font size instead of the parent one, or you need to set other properties to the parent font size, not the current one. If you’re already familiar with the problem and just want the solution, skip ahead. The next few paragraphs are for those thinking “but when would you ever need this?” Sometimes, there are workarounds, and it’s just a matter of keeping DRY. For example, take a look at this speech bubble:

  • General Meta Tags

    11
    • title
      Inherit ancestor font-size, for fun and profit • Lea Verou
    • charset
      UTF-8
    • viewport
      width=device-width, initial-scale=1
    • author
      Lea Verou
    • article:author
      Lea Verou
  • Open Graph Meta Tags

    3
    • og:title
      Inherit ancestor font-size, for fun and profit • Lea Verou
    • og:type
      article
    • og:description
      If you’ve been writing CSS for any length of time, you’re probably familiar with the em unit, and possibly the other type-relative units. We are going to refer to em for the rest of this post, but anything described works for all type-relative units. As you well know, em resolves to the current font size on all properties except font-size, where it resolves to the parent font size. It can be quite useful for making scalable components that adapt to their context size. However, I have often come across cases where you actually need to “circumvent” one level of this. Either you need to set font-size to the grandparent font size instead of the parent one, or you need to set other properties to the parent font size, not the current one. If you’re already familiar with the problem and just want the solution, skip ahead. The next few paragraphs are for those thinking “but when would you ever need this?” Sometimes, there are workarounds, and it’s just a matter of keeping DRY. For example, take a look at this speech bubble:
  • Twitter Meta Tags

    2
    • twitter:title
      Inherit ancestor font-size, for fun and profit • Lea Verou
    • twitter:description
      If you’ve been writing CSS for any length of time, you’re probably familiar with the em unit, and possibly the other type-relative units. We are going to refer to em for the rest of this post, but anything described works for all type-relative units. As you well know, em resolves to the current font size on all properties except font-size, where it resolves to the parent font size. It can be quite useful for making scalable components that adapt to their context size. However, I have often come across cases where you actually need to “circumvent” one level of this. Either you need to set font-size to the grandparent font size instead of the parent one, or you need to set other properties to the parent font size, not the current one. If you’re already familiar with the problem and just want the solution, skip ahead. The next few paragraphs are for those thinking “but when would you ever need this?” Sometimes, there are workarounds, and it’s just a matter of keeping DRY. For example, take a look at this speech bubble:
  • Link Tags

    5
    • alternate
      ../../../../feed.xml
    • dns-prefetch
      https://kit.fontawesome.com
    • shortcut icon
      ../../../../mark.svg
    • stylesheet
      ../../../../assets/style.css
    • stylesheet
      https://kit.fontawesome.com/040e756b7e.css

Links

39