0

I have a blue underline that I'm having trouble removing. I'm pretty sure that it is either a border:none or text-decoration:none problem, but I can't seem to find the solution.

Here is a screenshot of my problem:

HTML:

<a href="#top"><div class="content_tab" id="first_tab">
    <span class="tab_text_centred">Back to top</span>
</div></a>

CSS:

.content_tab {
    width: 220px;
    height: 340px;
    margin-right: 0px;
    margin-bottom: 20px;
    float: left;
    background-color: #000;

    overflow: hidden;
    color: #FFF;
    font-family: Georgia, Times ,serif;
    font-size: 30px;
    font-style: italic;
}
#first_tab {
    background-color: #1b1c20;
    text-align: center;
}
.tab_text_centred {
    position:relative;
    top:153px;
}

JSFIDDLE: http://jsfiddle.net/craigzilla/DptMf/

heisenberg
  • 9,665
  • 1
  • 30
  • 38

5 Answers5

2

You can not put a tags around a div in pre-HTML5. This is not how you make a div and it's contents link clickable in pre-HTML5. It seems your issue could be connected to a text decoration issue caused by the use of this tag in this manner. Ensure you adopt the correct way for HTML 4.01 or keep it as you have but ensure you use the correct declaration in the head of your document.

Kevin Lynch
  • 24,427
  • 3
  • 36
  • 37
2

A tag have the default property display:inline. DIV tag have defaut property: display:block. A tag wrap DIV tag is not incompatible with W3C. With your case, it can be more simple as below:

HTML code:

<a href="#top" class="content_tab" id="first_tab">
    <span class="tab_text_centred">Back to top</span>
</a>

CSS code:

.content_tab {
    width: 220px;
    height: 340px;
    line-height: 340px;
    margin-right: 0px;
    margin-bottom: 20px;
    float: left;
    background-color: #000;
    overflow: hidden;
    color: #FFF;
    font-family: Georgia, Times ,serif;
    font-size: 30px;
    font-style: italic;
}
#first_tab {
    background-color: #1b1c20;
    text-align: center;
}
saosangmo
  • 62
  • 5
1

I don't see anything but make sure you haven't got anything underlined by doing the following, then try again.

a, a:focus, a:active, a:hover, a:visited {
    text-decoration:none;
}
rob_mccann
  • 1,237
  • 2
  • 11
  • 16
1

I don't see the line in your fiddle using Chrome, but that's a lot of extra markup.

http://jsfiddle.net/DptMf/2/

<a href="#top" class="content_tab" id="first_tab"> Back to top </a>

.content_tab {
    width: 220px;
    height: 340px;
    line-height:340px;
    margin-right: 0px;
    margin-bottom: 20px;
    float: left;
    background-color: #000;
    text-decoration:none;
    overflow: hidden;
    color: #FFF;
    font-family: Georgia, Times ,serif;
    font-size: 30px;
    font-style: italic;
}
#first_tab {
    background-color: #1b1c20;
    text-align: center;
}

Is putting a div inside an anchor ever correct?

Community
  • 1
  • 1
Andrew Clody
  • 1,171
  • 6
  • 13
0

As specified by another person:

'You can not put a tags around a div. This is not how you make a div and it's contents link clickable.

This applies to pre-HTML5, and support for a tags is low. I think it's a text decoration issue caused by this action.