Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 970803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:51:39+00:00 2026-05-16T02:51:39+00:00

I have an icon that I would like to be able to drop into

  • 0

I have an icon that I would like to be able to drop into text at arbitrary points and have it “flow” with the text.

Background:

An <img> tag works best for this. However, I don’t want to have to specify the href everywhere. That will present problems in the future should the icon/location change. It also depends on me knowing the path to the image which I won’t always know due to URL-rewrites and different mappings to the same page, etc. I would like to do something like <span class="icon"></span> and have my icon as the background-image. Of course, this doesn’t work since you can’t have width on an inline element. Having it as a block (ie. <div>) element doesn’t work (for obvious reasons) and floating it doesn’t work either. display: inline-block; works in some browsers but not all. Using padding: to pad-out the correct height and width gives mixed results in different browsers. Using an <img> tag with a transparent image for the href and a background-image
works but seems hacky.

Any thoughts on what the best way to accomplish this would be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:51:40+00:00Added an answer on May 16, 2026 at 2:51 am

    You could make the <span class="icon"></span> absolutely positioned within your link like so:

    <a href="">Some text <span class="icon"></span></a>
    

    You can specify width/height on absolutely positioned elements, so the CSS would look something like this:

    a {
        position: relative;
        padding-right: 30px; /* width of your icon, assuming you're placing to the right of the text */
    }
    
    a .icon {
        display: block; /* for good measure, but won't be required in all browsers */
        position: absolute;
        top: 0;
        right: 0;
    
        width: 30px;
        height: 30px;
    
        background: url(your-icon.png) no-repeat 0 0;
    }
    

    By setting the <a>‘s postion to relative, it makes it the coordinate system for the absolutely positioned <span class="icon">.

    Using an Image Tag for the Icon

    If you don’t know where the icon will appear, you can use an <img> tag with a transparent .gif as its source.

    <p>Lorem ipsum <img src="clear.gif" alt="icon" class="icon" /> dolar velarium</p>
    

    Then set the real icon source using the CSS background property:

    img.icon {
        height: 30px;
        width: 30px;
        background: url(true-icon-src.png) no-repeat 0 0;
    
        /* Use the following if you want to adjust the image's vertical position */
        position: relative;
        top: 5px;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written an editor that I would like to be able to handle
I have drawn an icon in Inkscape , but would now like to programmatically
I have an icon inside a list, I'd like to just be able to
I would like to create a notification icon view that looks similar to the
I have a really trivial perl script that I would like to distribute to
We have a special mobile version of our site that we would like to
I would like to have a Java component which has a resize icon on
I would like to have a Text plus image button in a row. if
I have a home-screen widget that has an icon that starts/so pose to bring
I have a simple Tray icon program that opens a site using System.Diagnostics.Process.Start(URL) And

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.