<?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: carollin rolling</title>
    <description>The latest articles on DEV Community by carollin rolling (@carollin_rolling_a3f2b9ed).</description>
    <link>https://dev.to/carollin_rolling_a3f2b9ed</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4201833%2F6f5a1dac-5f46-405f-a0b6-69af5980347f.png</url>
      <title>DEV Community: carollin rolling</title>
      <link>https://dev.to/carollin_rolling_a3f2b9ed</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/carollin_rolling_a3f2b9ed"/>
    <language>en</language>
    <item>
      <title>How to Check Whether a Backlink Exists in Raw HTML with Python</title>
      <dc:creator>carollin rolling</dc:creator>
      <pubDate>Fri, 06 Nov 2026 09:15:13 +0000</pubDate>
      <link>https://dev.to/carollin_rolling_a3f2b9ed/how-to-check-whether-a-backlink-exists-in-raw-html-with-python-p8d</link>
      <guid>https://dev.to/carollin_rolling_a3f2b9ed/how-to-check-whether-a-backlink-exists-in-raw-html-with-python-p8d</guid>
      <description>&lt;p&gt;A page can mention a website without linking to it. The address might appear as plain text, inside a comment, or in a JavaScript object. Searching the source for a domain will find those mentions, too.&lt;/p&gt;

&lt;p&gt;That distinction matters when you maintain a spreadsheet of directory listings, resource pages, or website references. Before marking a placement as a link, check whether an &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; element actually points to the destination.&lt;/p&gt;

&lt;p&gt;Here is a small Python tool for that check. It reads an HTML file you have saved locally and prints matching anchor tags, including their source line numbers. It uses the standard library and makes no network requests.&lt;/p&gt;

&lt;h2&gt;
  
  
  A domain mention and an anchor are different things
&lt;/h2&gt;

&lt;p&gt;This is a mention:&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;p&amp;gt;&lt;/span&gt;Website: https://example.org/&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is an anchor with a destination:&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;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://example.org/"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"ugc nofollow"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Website&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;href&lt;/code&gt; attribute is the important difference. Google's &lt;a href="https://developers.google.com/search/docs/crawling-indexing/links-crawlable" rel="noopener noreferrer"&gt;link best practices&lt;/a&gt; describe &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; elements with &lt;code&gt;href&lt;/code&gt; attributes as the standard crawlable format. An anchor's presence alone does not establish its indexing or ranking effect.&lt;/p&gt;

&lt;p&gt;For this walkthrough, the destination to look for is &lt;a href="https://rummy91apk.app/" rel="noopener noreferrer"&gt;rummy91apk.app&lt;/a&gt;. The example concerns HTML link detection; it does not evaluate the destination's content, ownership, or downloads.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Save the source you want to inspect
&lt;/h2&gt;

&lt;p&gt;Open the page that is supposed to contain the link. Use &lt;strong&gt;View Page Source&lt;/strong&gt;, then save that source as a UTF-8 file named &lt;code&gt;source.html&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Alternatively, use your browser's Network panel to inspect the main document's response and save its HTML. Record the final document URL after any redirects. The script needs that URL to resolve relative links.&lt;/p&gt;

&lt;p&gt;Keep the distinction between the source and the rendered page in mind. The browser's Elements panel can show changes made by JavaScript after the initial response. This script examines only the file you provide.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Parse anchors instead of searching for strings
&lt;/h2&gt;

&lt;p&gt;Save the following as &lt;code&gt;audit_links.py&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;argparse&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;html.parser&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HTMLParser&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib.parse&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;urljoin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;urlsplit&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AnchorParser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTMLParser&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;base_href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;anchors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;handle_starttag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attrs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;attrs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attrs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;attrs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;href&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;base&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;base_href&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;base_href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;a&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;anchors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getpos&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_starttag_text&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;url_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;parts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;urlsplit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scheme&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;netloc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
    &lt;span class="nf"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scheme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;netloc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;cli&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;argparse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ArgumentParser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;cli&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;html_file&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cli&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;source_url&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cli&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;target_url&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cli&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse_args&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;url_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;target_url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;cli&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;target_url must be an absolute HTTP or HTTPS URL&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;parser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AnchorParser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;html_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;utf-8&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;urljoin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;base_href&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;matches&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;markup&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;anchors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;url_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;urljoin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Line &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;markup&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;matches&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No matching &amp;lt;a href&amp;gt; found in this HTML file.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python's &lt;a href="https://docs.python.org/3/library/html.parser.html" rel="noopener noreferrer"&gt;&lt;code&gt;HTMLParser&lt;/code&gt;&lt;/a&gt; provides parsed tags and attributes. &lt;a href="https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin" rel="noopener noreferrer"&gt;&lt;code&gt;urljoin&lt;/code&gt;&lt;/a&gt; resolves relative URLs against the document URL, or against its first &lt;code&gt;&amp;lt;base href&amp;gt;&lt;/code&gt; when one is present.&lt;/p&gt;

&lt;p&gt;The script prints the original opening tag so you can inspect attributes such as &lt;code&gt;rel&lt;/code&gt; without losing their values.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Run it against a small fixture first
&lt;/h2&gt;

&lt;p&gt;Before checking a real source file, save this as &lt;code&gt;source.html&lt;/code&gt;:&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="cp"&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Plain text: https://rummy91apk.app/&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://rummy91apk.app/"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"ugc nofollow"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Website&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;destination&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://rummy91apk.app/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python audit_links.py source.html https://listing.example/profile https://rummy91apk.app/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The middle URL represents the page whose HTML you saved. For this local fixture, it is a placeholder. When auditing an actual page, replace it with that page's final URL.&lt;/p&gt;

&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Line 3: &amp;lt;a href="https://rummy91apk.app/" rel="ugc nofollow"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Although the destination appears three times in the fixture, only one occurrence is an anchor. Remove that anchor and run the command again. The script should report that it found no matching &lt;code&gt;&amp;lt;a href&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Keep URL matching conservative
&lt;/h2&gt;

&lt;p&gt;The script ignores fragments, so a URL ending in &lt;code&gt;#details&lt;/code&gt; matches the same document URL without the fragment. It also treats an empty root path and &lt;code&gt;/&lt;/code&gt; as equivalent.&lt;/p&gt;

&lt;p&gt;Other distinctions remain intact:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTP and HTTPS are separate.&lt;/li&gt;
&lt;li&gt;A hostname with &lt;code&gt;www&lt;/code&gt; and one without it are separate.&lt;/li&gt;
&lt;li&gt;Query strings remain part of the comparison.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/guide&lt;/code&gt; and &lt;code&gt;/guide/&lt;/code&gt; are separate paths.&lt;/li&gt;
&lt;li&gt;Explicit port numbers remain in the comparison.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This avoids silently assuming that different addresses lead to the same place. The tool does not follow redirects or establish canonical URLs. It assumes ordinary, well-formed web URLs; it is not a general URL validator.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Report what the file actually proves
&lt;/h2&gt;

&lt;p&gt;A useful audit note might read:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Matching anchor found in saved source, line 3. The opening tag includes &lt;code&gt;rel="ugc nofollow"&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is more precise than recording only “backlink present.” It preserves the evidence and the link attributes without making a claim about SEO value.&lt;/p&gt;

&lt;p&gt;If the script finds nothing, record that narrower result: &lt;strong&gt;no matching anchor found in the inspected HTML file&lt;/strong&gt;. A link could still be inserted during rendering, point through a redirect URL, or appear in content missing from that response.&lt;/p&gt;

&lt;p&gt;This is a source-markup check, not a browser visibility test. It can find anchors in hidden or inert markup, including templates. For a live-page assessment, inspect the rendered DOM and the surrounding content as well.&lt;/p&gt;

&lt;p&gt;For a spreadsheet, useful columns are the source URL, target URL, inspection date, matching tag, &lt;code&gt;rel&lt;/code&gt; value, and whether the evidence came from the original response or the rendered DOM. Those details make the result easier to reproduce when a page changes.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Designing an Empty State Before Generating the Illustration</title>
      <dc:creator>carollin rolling</dc:creator>
      <pubDate>Tue, 27 Oct 2026 07:59:31 +0000</pubDate>
      <link>https://dev.to/carollin_rolling_a3f2b9ed/designing-an-empty-state-before-generating-the-illustration-58jp</link>
      <guid>https://dev.to/carollin_rolling_a3f2b9ed/designing-an-empty-state-before-generating-the-illustration-58jp</guid>
      <description>&lt;p&gt;An empty dashboard is a surprisingly awkward thing to design.&lt;/p&gt;

&lt;p&gt;Leave it blank, and the page looks unfinished. Add a large illustration, and suddenly a project management app looks like a greeting card.&lt;/p&gt;

&lt;p&gt;Then there’s the familiar message underneath:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Nothing here yet!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Friendly enough. But what should the user do next?&lt;/p&gt;

&lt;p&gt;Before choosing an illustration, it helps to work out what the empty page needs to explain.&lt;/p&gt;

&lt;p&gt;Let’s use a bookmarks app as an example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with the reason the page is empty
&lt;/h2&gt;

&lt;p&gt;A bookmarks page can be empty because someone has just created an account. It can also be empty because their search returned no matches.&lt;/p&gt;

&lt;p&gt;Those situations need different responses.&lt;/p&gt;

&lt;p&gt;For a new account:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Save your first bookmark&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Add a link you want to come back to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add bookmark&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For an unsuccessful search:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;No bookmarks match “CSS grid”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Try another search or remove a filter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Clear search&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A welcome illustration might fit the first state. Reusing it for the second could make the app appear to have lost the user’s saved links.&lt;/p&gt;

&lt;p&gt;The illustration belongs to a particular state, just like the heading and button.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give the illustration one job
&lt;/h2&gt;

&lt;p&gt;For the first-use state, the visual could show a bookmark going into a small tray.&lt;/p&gt;

&lt;p&gt;That is enough.&lt;/p&gt;

&lt;p&gt;It does not need a person, a desk, a laptop, floating browser windows, three plants, and a rocket.&lt;/p&gt;

&lt;p&gt;At the size used in an interface, extra objects compete with the thing the illustration is supposed to communicate.&lt;/p&gt;

&lt;p&gt;A useful brief might be:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A small tray with one bookmark card hovering above it. Simple shapes, limited colors, no lettering. Intended for the empty bookmarks page of a web app.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is specific about the subject and where it will appear. It leaves room to explore the visual style.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generate a draft against that brief
&lt;/h2&gt;

&lt;p&gt;You can use &lt;a href="https://www.piclumen.com/" rel="noopener noreferrer"&gt;PicLumen&lt;/a&gt; to explore an illustration from the brief, then judge the result against the actual component.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Minimal flat illustration for a bookmarks app empty state. One rounded bookmark card hovering above a shallow tray. Muted blue and warm gray palette, simple geometric shapes, front three-quarter view, isolated on a plain white background. No text, no logos, no surrounding interface.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Keep the heading and button out of the generated image. They should remain HTML text so they can be edited, translated, and resized with the rest of the interface.&lt;/p&gt;

&lt;p&gt;The generated draft also needs inspection. Look for odd overlaps, unnecessary details, and shadows that make the composition harder to read.&lt;/p&gt;

&lt;p&gt;A result can look appealing on its own and still be a poor fit for the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review it at the size you will ship
&lt;/h2&gt;

&lt;p&gt;Open the illustration inside the empty-state component.&lt;/p&gt;

&lt;p&gt;If the planned display width is 160 pixels, review it at 160 pixels. A full-screen preview will hide some practical problems.&lt;/p&gt;

&lt;p&gt;Check whether:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The bookmark still reads as a bookmark.&lt;/li&gt;
&lt;li&gt;Thin lines disappear.&lt;/li&gt;
&lt;li&gt;The shadow looks too heavy.&lt;/li&gt;
&lt;li&gt;Empty margins make the drawing appear smaller than expected.&lt;/li&gt;
&lt;li&gt;The image attracts more attention than the action button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the concept only works when enlarged, simplify it before spending time polishing the details.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let the markup carry the meaning
&lt;/h2&gt;

&lt;p&gt;For this example, the illustration repeats information already conveyed by the heading and description. It can have an empty alt attribute:&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;section&lt;/span&gt;
  &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"empty-state"&lt;/span&gt;
  &lt;span class="na"&gt;aria-labelledby=&lt;/span&gt;&lt;span class="s"&gt;"empty-bookmarks-title"&lt;/span&gt;
&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt;
    &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/images/empty-bookmarks.webp"&lt;/span&gt;
    &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;
    &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"160"&lt;/span&gt;
    &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"120"&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;id=&lt;/span&gt;&lt;span class="s"&gt;"empty-bookmarks-title"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Save your first bookmark
  &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;Add a link you want to come back to.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"button"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Add bookmark
  &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The button still needs to be connected to the app’s add-bookmark flow.&lt;/p&gt;

&lt;p&gt;If an illustration communicates information that is missing from the text, reconsider that decision. Instructions someone needs to use the page should be available without interpreting the picture.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the component without the image
&lt;/h2&gt;

&lt;p&gt;Temporarily hide the illustration.&lt;/p&gt;

&lt;p&gt;Can someone still understand what this page is for and what to do next?&lt;/p&gt;

&lt;p&gt;In the bookmarks example, they should be able to. The heading explains the starting point, the description gives a small amount of context, and the button names the action.&lt;/p&gt;

&lt;p&gt;Then bring the illustration back.&lt;/p&gt;

&lt;p&gt;Its contribution should be visible: it makes the page feel considered, introduces the visual style, or helps someone recognize the situation.&lt;/p&gt;

&lt;p&gt;If it pushes the button down the screen without adding much, making it smaller—or leaving it out—is a reasonable design decision.&lt;/p&gt;

&lt;p&gt;The empty state is finished when the next step is clear. The illustration gets its place by helping that page work.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Getting an AI Image to Work in a Website Hero</title>
      <dc:creator>carollin rolling</dc:creator>
      <pubDate>Mon, 26 Oct 2026 10:13:54 +0000</pubDate>
      <link>https://dev.to/carollin_rolling_a3f2b9ed/getting-an-ai-image-to-work-in-a-website-hero-537j</link>
      <guid>https://dev.to/carollin_rolling_a3f2b9ed/getting-an-ai-image-to-work-in-a-website-hero-537j</guid>
      <description>&lt;p&gt;Generate a wide image, put a headline over it, then open the page on your phone.&lt;/p&gt;

&lt;p&gt;The cup is cropped out. The empty space is gone. The headline now sits over the busiest part of the picture.&lt;/p&gt;

&lt;p&gt;A 16:9 image gives you a starting shape. The layout determines how much of it anyone actually sees. That is worth figuring out before spending an afternoon rewriting prompts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give the image a job in the layout
&lt;/h2&gt;

&lt;p&gt;Take a simple landing page: headline on the left, a ceramic coffee cup on the right, one button below the copy.&lt;/p&gt;

&lt;p&gt;Before generating the image, put the actual headline and button into a rough layout. Use a solid rectangle for the image if necessary. You want to know where the text ends and where the cup can begin.&lt;/p&gt;

&lt;p&gt;This matters more than it sounds. “Leave space on the left” could mean room for a short heading. Your page might need room for a three-line heading, a description, and two buttons.&lt;/p&gt;

&lt;p&gt;For this example, the image brief could be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cup in the right third of the frame.&lt;/li&gt;
&lt;li&gt;Left half reserved for text.&lt;/li&gt;
&lt;li&gt;Warm, low-detail background.&lt;/li&gt;
&lt;li&gt;No lettering or decorative objects behind the copy.&lt;/li&gt;
&lt;li&gt;Mobile layout places the copy above the image.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last decision takes some pressure off the image. It only needs to support overlapping text on wider screens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Put those constraints into the prompt
&lt;/h2&gt;

&lt;p&gt;A scene prompt might look like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A ceramic coffee cup on a wooden desk, warm morning light, realistic photography.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is nothing in that request about a website. A centered cup, a plant on the left, and a sharply defined window frame would all fit the description.&lt;/p&gt;

&lt;p&gt;Here is a more useful brief for our layout:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Wide photograph for a website hero, 16:9. A cream ceramic coffee cup on a pale wooden desk, positioned in the right third. Warm morning light from the right. The left half shows a plain, softly lit beige wall with very little texture, reserved for a headline and button. Keep the cup fully inside the frame. No lettering, logos, plants, or extra desk objects.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The useful details are spatial: where the cup goes, what sits behind the text, and which objects would get in the way.&lt;/p&gt;

&lt;p&gt;The model may ignore some of them. Treat the output as a draft.&lt;/p&gt;

&lt;p&gt;When reviewing it, use the page mockup. If the cup overlaps the copy, ask for a position change. If a window frame cuts through the letters, remove the window frame. Keep revisions specific enough that you can tell whether they helped.&lt;/p&gt;

&lt;p&gt;Changing the subject position, lighting, palette, and camera angle at once makes that harder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understand what &lt;code&gt;cover&lt;/code&gt; will crop
&lt;/h2&gt;

&lt;p&gt;Suppose the source image is 1600 × 900, and the mobile image box is 400 × 500.&lt;/p&gt;

&lt;p&gt;With &lt;code&gt;object-fit: cover&lt;/code&gt;, the image scales to roughly 889 × 500 to fill the box without distortion. The box shows about 45% of the image’s width.&lt;/p&gt;

&lt;p&gt;That is a lot of composition to lose. The cup and the space beside it might simply be too far apart to survive together.&lt;/p&gt;

&lt;p&gt;For an &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element, &lt;code&gt;object-position&lt;/code&gt; lets you adjust which area remains visible:&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;.hero__image&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;block&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;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;20rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;40vw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;36rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;object-fit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;cover&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;object-position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;75%&lt;/span&gt; &lt;span class="nb"&gt;center&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;Here, &lt;code&gt;75% center&lt;/code&gt; favors the right-hand portion when there is horizontal cropping. It does not detect the cup or guarantee that the whole cup stays visible. MDN explains how &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/object-fit" rel="noopener noreferrer"&gt;object-fit&lt;/a&gt; and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/object-position" rel="noopener noreferrer"&gt;object-position&lt;/a&gt; interact.&lt;/p&gt;

&lt;p&gt;For our example, the mobile design already puts the copy above the image. We can let the image keep its natural proportions there:&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="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;48rem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.hero__image&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&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;This snippet handles the image sizing; the surrounding component still needs to arrange the copy and image at that breakpoint.&lt;/p&gt;

&lt;p&gt;If the mobile design requires a tall image, a separate composition may be a better fit. Decide that from the layout rather than repeatedly trying to generate a landscape image that tolerates every possible crop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the background behind the actual letters
&lt;/h2&gt;

&lt;p&gt;A quiet background helps, but it does not establish sufficient contrast by itself.&lt;/p&gt;

&lt;p&gt;Pale beige can look restrained and still be a poor background for white text. A dark image can contain one reflection that makes a few words difficult to read.&lt;/p&gt;

&lt;p&gt;Check the parts of the image directly behind the heading, description, and button label. Repeat after changing the crop.&lt;/p&gt;

&lt;p&gt;For normal-size text, WCAG’s minimum contrast requirement is 4.5:1. The &lt;a href="https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html" rel="noopener noreferrer"&gt;W3C explanation&lt;/a&gt; covers the criterion and its exceptions.&lt;/p&gt;

&lt;p&gt;An overlay is one option. Putting the copy on a solid background is another. If the design needs several layers of fixes to make the heading readable, revisit the composition.&lt;/p&gt;

&lt;p&gt;Keep the heading and button in HTML, too. Copy changes and translations are much easier when they do not require a new image.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review the asset in the browser before calling it finished
&lt;/h2&gt;

&lt;p&gt;Use the real headline. Resize slowly through the widths between your usual desktop and mobile previews. Check what happens when the heading wraps onto another line.&lt;/p&gt;

&lt;p&gt;Then look at the image at its displayed size. A distorted cup handle may be obvious there, even if it was easy to miss in a thumbnail. Conversely, tiny background details may have no bearing on the finished page.&lt;/p&gt;

&lt;p&gt;For accessibility, decide what the image contributes. A purely decorative &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; should use &lt;code&gt;alt=""&lt;/code&gt;. An image that communicates additional information needs an appropriate text alternative. W3C’s &lt;a href="https://www.w3.org/WAI/tutorials/images/decorative/" rel="noopener noreferrer"&gt;decorative image guidance&lt;/a&gt; explains that distinction.&lt;/p&gt;

&lt;p&gt;Save the composition brief with the selected asset. When the headline gets longer or the layout changes, you will have something more useful to revise than “make it look better.”&lt;/p&gt;

&lt;p&gt;For a hero section, the browser is where the image earns its place. Approve it there.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
