0

So I made a div as a box with text. When I then put it in < a href="#" > tag It looks like this:

https://i.gyazo.com/8103b9cc1968842e88afa4c4971b64ea.png

My problem is that I can't remove the line under the text.

My code:

HTML:

<div class="sommersalg">

    <div id="prosent">
        50%-75%
    </div>

    <p>SOMMERSALG</p>

    <a href="produkter.html">
        <div id="handle">
            HANDLE NÅ
        </div>
    </a>

</div>

CSS

.sommersalg a #handle {

    margin: auto;
    border-radius: 7.5px;
    position: relative;
    top: -290px;
    color: #586e72;
    background-color: white;
    font-size: 15px;
    width: 250px;
    padding: 15px;
    text-align: center;
    font-family: 'Raleway', sans-serif;
    cursor: pointer;
    box-shadow: 0px 2px 5px #3686a3;
    text-decoration: none;
}

.sommersalg #handle:hover {
    top: -289.25px;
    box-shadow: 0px 0px 0px #3686a3;
    text-decoration: none;
}

3 Answers3

4

You have to set the <a> tag to text-decoration: none;. Not the div inside.

.sommersalg a #handle {

    margin: auto;
    border-radius: 7.5px;
    position: relative;
    top: -290px;
    color: #586e72;
    background-color: white;
    font-size: 15px;
    width: 250px;
    padding: 15px;
    text-align: center;
    font-family: 'Raleway', sans-serif;
    cursor: pointer;
    box-shadow: 0px 2px 5px #3686a3;
    text-decoration: none;
}

.sommersalg #handle:hover {
    top: -289.25px;
    box-shadow: 0px 0px 0px #3686a3;
    text-decoration: none;
}

.sommersalg a {
  text-decoration: none;
 }
<div class="sommersalg">

    <div id="prosent">
        50%-75%
    </div>

    <p>SOMMERSALG</p>

    <a href="produkter.html">
        <div id="handle">
            HANDLE NÅ
        </div>
    </a>

</div>
Jan Franta
  • 1,521
  • 2
  • 14
  • 24
0

first of all put the text inside of a p tag , then use this code in your CSS file :

#handle > p { text-decoration:none;}

instead of p tag u also can use span , by then your css should be :

#handle > span {text-decoration:none;}

just note that p is blocked by nature (means that it takes whole width) but span is not and it just takes what ever it needs from width!

a_m_dev
  • 4,228
  • 5
  • 29
  • 54
0

The problem is with div element inside the element, as discussed here. Have you added an html doctype?

The "text-decoration: none;" is all right in .sommersalg a. You do not need to add a :hover part.

Geff
  • 142
  • 1
  • 12