0

I am trying to remove an underline from an href, that is wrapped in a div element. But for some reason it is not being removed.

Can anyone please help me? Below is the code.

 <style>


     a .menu_items {
        text-decoration:none;
        font-size: 34px;
        color:red;

    }

   </style>
    </head>
    <body>

                <a href="#"><div class="menu_items"> Pizza  </div></a>
Eldan Shkolnikov
  • 441
  • 1
  • 6
  • 13
  • Exact duplicate of http://stackoverflow.com/questions/5207345/css-how-do-i-remove-the-underline-from-a-link-that-isnt-directly-in-the-anchor – Fabrizio Calderan Jun 11 '14 at 16:03

7 Answers7

3

Try this:

a {
text-decoration:none;
}

Cause you are trying add text-decoration to the div with class .menu_items but not for tag a

user3127896
  • 6,323
  • 15
  • 39
  • 65
2

you can do this and it will be easier after developing more pages and you will not have to create a style for each one you only have to call your style from your css

i explain you...you have to found your css default in your project or create a new one and load in your page where you want to call the styles that you will create in your css file....insert this in your css

 a {
    text-decoration:none;
    font-size: 34px;
    color:red;

}

and in your page after loading your css file you only have to copy this as you were codding

    <body>    
                <a href="#"><div class="menu_items"> Pizza  </div></a>
</body>

i hope i helped you

MickyScion
  • 526
  • 2
  • 14
0

Please try putting the A link inside the DIV then reverse the CSS order. I believe the other way around is not valid.

0

just delete the selector '.menu_items' like this

<style>
    a {
        text-decoration:none;
        font-size: 34px;
        color:red;
    }

</style>
<a href="#">
    <div class="menu_items"> 
        Pizza  
    </div>
</a> 

here's the jsfiddle

Felipe Barnett
  • 407
  • 4
  • 10
0

The CSS property for removing the underline is

text-decoration:underline;

You will need to apply this to your anchor element.

See this here-> http://jsfiddle.net/CzDkH/

Hope this helps!!!

Satwik Nadkarny
  • 5,086
  • 2
  • 23
  • 41
0

Place this above all your styles:

a {
    text-decoration:none;
}

Get in the habit of placing all a , html , and body style properties at the top of your styles too! It will save you from headaches like this.

Happy styling :)

Michael
  • 9,639
  • 3
  • 64
  • 69
0

If you only want to do it for the class "menu_items" and not in the rest of the page, the only thing is you've got it back to front. It's like this:

   .menu_items a {
        text-decoration:none;
        font-size: 34px;
        color:red;

    }

Similarly you've got the div inside the a tag, and should have the a tag inside the div

<div class="menu_items"><a href="#">Pizza</a></div>
Robert Walker
  • 161
  • 1
  • 4