Blue hyperlink border around images in HTML
Blue Hyperlink Border Around Images in HTML
When an image is wrapped in a hyperlink, many browsers historically rendered a visible blue border around the image. While this behavior helped users identify clickable elements, it often results in pages that look unpolished or visually inconsistent—especially on technical documentation and industrial automation websites.
On engineering-focused sites like Chipkin’s, images are frequently used for diagrams, wiring examples, protocol illustrations, and product photos. In these cases, an unexpected blue border adds visual noise and detracts from clarity. Fortunately, this behavior can be disabled using either CSS or inline styling.
Method 1: Removing the Border Using CSS (Recommended)
The preferred approach is to remove image borders using CSS. This ensures consistent behavior across the entire site and avoids repeating inline styles on every image.
Add the following rule to your stylesheet:
img {
border-style: none;
}
In many cases, it is better to scope this rule specifically to linked images to avoid affecting images that intentionally use borders for visual separation or emphasis:
a img {
border: 0;
}
This approach removes the legacy hyperlink border while allowing the rest of your CSS and layout rules to remain unchanged.
Method 2: Removing the Border Inline (Legacy / Targeted Use)
In older HTML implementations, browsers applied borders directly to images inside hyperlinks. A common workaround was to explicitly disable the border on the image itself.
Because some CMS platforms aggressively sanitize or reinterpret HTML, the safest way to document this example is to show it using pseudo-HTML syntax rather than real tags.
Your code should look like this:
{a href="#"}
{img src="image.png" style="border: 0;" alt=""}
{/a}
This example illustrates the structure clearly without risking broken markup or unintended links on the page. The border: 0 style prevents browsers from rendering a visible border around the image.
Practical Notes for Technical Documentation
When documenting HTML techniques on industrial or engineering websites, it is important to balance correctness with robustness. Many content management systems will re-parse or sanitize HTML examples, which can result in broken layouts or links that never terminate.
Using pseudo-HTML (curly-brace notation) inside preformatted blocks avoids these issues entirely while remaining easy for engineers and developers to understand.
- Use CSS for site-wide consistency whenever possible.
- Use inline styles only when working within constrained templates.
- Avoid real angle-bracket tags in documentation examples unless the CMS explicitly supports them.
- Always include an alt attribute for accessibility and clarity.
Frequently Asked Questions (FAQ)
Why does the blue border appear around linked images?
The border originates from older browser defaults that visually marked linked images. While modern browsers rely more on focus outlines, legacy behavior can still appear depending on CSS resets and theme styles.
Is removing the border safe?
Yes. Removing the border does not affect functionality. However, you should ensure that linked images still provide a clear interaction cue, such as a hover effect or caption.
Why not show real HTML tags in the example?
Some CMS platforms re-interpret angle-bracket tags even inside code blocks, which can result in broken markup. Pseudo-HTML avoids this entirely.
Is inline styling still acceptable?
Inline styles are acceptable for small, targeted fixes or legacy systems, but CSS remains the preferred approach for maintainability.
5 Comments on Blue hyperlink border around images in HTML
5 Responses to Blue hyperlink border around images in HTML
-
Ashok says:
October 27, 2010 at 12:16 pm
Great trick. That helps!
-
eden says:
February 1, 2011 at 6:25 am
fantastic! just what i was looking for. thanks
-
shisu says:
June 14, 2011 at 9:57 pm
thanks for your little help this blue border is annoying..
thanks a lot ..
-
gautam says:
April 6, 2012 at 11:28 pm
hey thanks a lot. :)
-
Archana AKR says:
May 14, 2016 at 4:16 am
it really helped me ^_^