www.webdeveloper.com
Results 1 to 8 of 8

Thread: Getting rid of link underline in Firefox?

  1. #1
    Join Date
    Aug 2010
    Posts
    82

    Question Getting rid of link underline in Firefox?

    On my site I'm putting links around some images, like this page:
    http://www.girlscoutsmoheartland.org/pages/shop.php
    where the HTML looks like this example:
    HTML Code:
    <a href="/docs/shop/Shop Order Form.pdf" target="_blank"><img src="/images/files_tiny.gif" alt="retail form" width="18" height="19" border="0" align="absmiddle" />Use this one</a> for <strong>printing</strong> and filing out by hand,<br />
    The thing is, in Chrome and IE 7 and 8, the little image in the link shows no underline, which is what I want. But in Firefox, there's an annoying underline under the image.
    Unfortunately, we want the image next to the link to be linked as well, so I can't just move the image out of the anchor.
    Is there some CSS I can use to tell the browser don't underline a linked image?
    (I assume "text-decoration: none" would have no effect.)

    Thanks for any suggestions!

  2. #2
    Join Date
    Nov 2010
    Location
    Los Angeles, CA
    Posts
    234
    Is that your site that you have linked to? Because text-decoration: none worked for me in Firefox. It was in page-all.css line 481.

  3. #3
    Join Date
    Aug 2010
    Posts
    82
    Quote Originally Posted by Big O(1) View Post
    Is that your site that you have linked to? Because text-decoration: none worked for me in Firefox. It was in page-all.css line 481.
    Doh! I didn't make myself clear.
    The link text itself needs to stay underlined! (I'd prefer it wasn't, but I do what my boss says.) But the image needs to not have the underline (like it shows in IE and Chrome).
    Sorry for the confusion.
    Thanks for taking a look!

  4. #4
    Join Date
    Nov 2010
    Location
    Los Angeles, CA
    Posts
    234
    Oh, I see. Hmm.... If the image is part of the link, it will get the underline as well since it is a child of it. I can think of two solutions:

    1. Apply text-decoration: none to the <a>, and instead of using a regular image, use an image that includes the underline as a part of it. So in that example it will be that page icon with a line a little below it.
    2. Split up the <a> in two. So you will have <a><img><a> and right after it <a>text<a>. Apply text-decoration: none to just the second one. Make sure to give them both the same href. I prefer this method.

    These are just my ideas. If anybody has a better idea feel free to contribute.

  5. #5
    Join Date
    Nov 2010
    Location
    Los Angeles, CA
    Posts
    234
    Let me rephrase. I forgot you said you don't want the image to have an underline. So that means approach #1 gets thrown out the window, and approach #2 gets changed to applying text-decoration to just the first anchor.

  6. #6
    Join Date
    Aug 2010
    Posts
    82
    Quote Originally Posted by Big O(1) View Post
    Let me rephrase. I forgot you said you don't want the image to have an underline. So that means approach #1 gets thrown out the window, and approach #2 gets changed to applying text-decoration to just the first anchor.
    Thanks for the suggestion!
    That would work, but it would complicate things by requiring me to make sure I link twice which is a. something not easily remembered and b. clutters the HTML a bit. Also, it would mean having to also either put separate style or class attributes into the HTML.
    Instead, I just tried as a work-around, putting a -2px margin-bottom in the CSS. Seems to sorta solve that problem, and also puts the image more centered to the text so that's a plus.

    Not the most elegant solution, but it has the least side-effects.

    Thanks; I appreciate the reply!!

  7. #7
    Join Date
    Mar 2011
    Posts
    1
    This is a well known Firefox bug ... and unfortunately there isn't any coding solution in terms of CSS. All you can eventually do is just sort of a workaround. Set text-decoration: none; to the anchor. Image (a img) should have border: none; Create a span class like .underline {text-decoration: underline;} and apply it to text only in your links. Somethink like this:
    Code:
    <a href="/docs/shop/Shop Order Form.pdf" target="_blank"><img src="/images/files_tiny.gif" alt="retail form" width="18" height="19" border="0" align="absmiddle" /><span class="underline">Use this one</span></a> for <strong>printing</strong> and filing out by hand,<br />
    .... and the line on the bottom of your image will be gone.

  8. #8
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    Try This:
    (Tested via FireBug only, but should work across the board)

    HTML Code:
    /* float the image left, and strip out the funky margin hack, which will likely only cause headaches down the road */
    #content .linkimg { float: left; margin: 0 10px 0 0;}
    
    /* and to correct the floated image */
    #content a {display: inline-block; text-decoration: underline;}
    You might be able to get around the display: inline-block if your text was inside block-level <p> tags to begin with.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.14730 seconds
  • Memory Usage 2,920KB
  • Queries Executed 13 (?)
More Information
Template Usage (35):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (2)bbcode_html
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (8)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates