10
<a href="/admin/menu_bars/select">
    <div class="action_box right">
        Manage Menu Bars
    </div>
</a>


a .action_box {
text-decoration: none;
}

doesn't work =\

NullVoxPopuli
  • 61,906
  • 73
  • 206
  • 352
  • You cant have a `div` inside of an anchor. Use `span` instead. – Kyle Mar 05 '11 at 23:04
  • Note that `div`s can't be inside an anchor tag in any HTML standard. `div`s are block tags, while anchors are inline tags. And there can only be inline tags inside of other inlines. – Holger Just Mar 05 '11 at 23:06
  • If you change the div to a span element, or if you apply display:block to the anchor tag, that wouldnt be a problem' – Moses Mar 05 '11 at 23:09
  • 4
    @Kyle, @Holger Just: It is valid in HTML5, and the main reason it is is that all major browsers supported it even though it's not valid HTML4. So even if it's not valid right now, in practice, it'll work anywhere. (more infos there: http://html5doctor.com/block-level-links-in-html-5/) – zneak Mar 05 '11 at 23:10
  • thanks, I keep forgetting about that. haa. – NullVoxPopuli Mar 05 '11 at 23:34
  • duplicate post, your ans [here](http://stackoverflow.com/questions/2041388/how-to-remove-the-underline-for-anchorslinks) – Pran Dec 13 '15 at 20:42
  • This question is from a year before your answer – NullVoxPopuli Dec 13 '15 at 23:24

6 Answers6

16

Your code is trying to remove the underline from the div (which probably doesn't have one) rather than the link (which probably does). Simply

a {
text-decoration: none;
}

will work, although that will remove the underline from all links.

If you need to be more specific to that link then use

<a class="action_link" href="/admin/menu_bars/select">
    <div class="action_box right">
        Manage Menu Bars
    </div>
</a>


a.action_link {
text-decoration: none;
}

This assumes that the underline is in fact a text-decoration on the link element and not a border-bottom on the div.

Nico Burns
  • 16,639
  • 10
  • 40
  • 54
1

You still need to apply the text-decoration style to the outer href tag.

Example follows:

<html>
    <head>
        <style>
        .noUnderline {
        text-decoration: none;
        }
        </style>
    </head>
  <body>
    <a class="noUnderline" href="/admin/menu_bars/select">
        <div class="action_box">
            Manage Menu Bars
        </div>
    </a>
</body>
</html>
iwalkbarefoot
  • 955
  • 7
  • 15
1

Problem is, it's not putting the underline under the text, it's underlining the div. Basically you'd need to define the rule at the anchor still, not for the content inside the anchor:

a, a .action_box { text-decoration: none; }
Tim Stone
  • 19,119
  • 6
  • 56
  • 66
0

Can you not just use this.

#content > ul {
             text-decoration: none;
           }

The above obviously is my own.

0

It quite possibly could be an issue of another class / property is overriding your latest attempt; however, try what Silence Dogood said:

a div .action_box {
   text-decoration: none;
}

If that doesn't work we'll need to see the rest of the CSS.

Jeff Andersen
  • 332
  • 8
  • 14
0

You are trying to remove underline from div which is inside the anchor tag

Simply use

a{
text-decoration: none;
}

You can give id to anchor tag for better use,

<a id="linkid" href="/admin/menu_bars/select">
    <div class="action_box right">
        Manage Menu Bars
    </div>
</a>

and use css

a#linkid{

     text-decoration: none;
}
Smita Kagwade
  • 281
  • 1
  • 4
  • 12