{"id":103,"date":"2019-07-30T12:53:32","date_gmt":"2019-07-30T12:53:32","guid":{"rendered":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/?p=103"},"modified":"2019-07-30T19:50:26","modified_gmt":"2019-07-30T19:50:26","slug":"images-and-before-after","status":"publish","type":"post","link":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/2019\/images-and-before-after\/","title":{"rendered":"Images and ::before &#038; ::after"},"content":{"rendered":"<p>I learned today that the pseudo-elements ::before and ::after don&#8217;t work with the img-element. As I went looking I found out that the CSS spec is very unclear on this. It has to do with the fact that &lt;img&gt; doesn&#8217;t have its actual content on the page\/in the HTML, it pulls it in from elsewhere. This makes it a replaced element. Form elements are also replaced elements. It is also an empty element, like &lt;br&gt; and &lt;hr&gt;.<\/p>\n<p>Rule of thumb (for now) seems to be that empty elements can&#8217;t have ::before and ::after applied with the exception of &lt;hr&gt;.<br \/>\nOther empty elements with which ::before and ::after wont work (may) include form elements and &lt;br&gt;.<\/p>\n<hr \/>\n<div class=\"_3bJ2H CHExY\">\n<div class=\"_1l8RX _1ByhS\">Photo by <a href=\"https:\/\/unsplash.com\/@jackpk?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" target=\"_blank\" rel=\"noopener noreferrer\">Jack Krasky<\/a> on <a href=\"https:\/\/unsplash.com\/search\/photos\/before-and-after?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText\" target=\"_blank\" rel=\"noopener noreferrer\">Unsplash<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I learned today that the pseudo-elements ::before and ::after don&#8217;t work with the img-element. As I went looking I found out that the CSS spec is very unclear on this. It has to do with the fact that &lt;img&gt; doesn&#8217;t have its actual content on the page\/in the HTML, it pulls it in from elsewhere. &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Images and ::before &#038; ::after\" class=\"read-more button\" href=\"https:\/\/www.blindemanwebsites.com\/today-i-learned\/2019\/images-and-before-after\/#more-103\" aria-label=\"Read more about Images and ::before &#038; ::after\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":106,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[17,14,18],"class_list":["post-103","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-new-things","tag-css","tag-images","tag-pseudo-elements","infinite-scroll-item","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":0,"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/media\/106"}],"wp:attachment":[{"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blindemanwebsites.com\/today-i-learned\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}