Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8799167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:15:18+00:00 2026-06-14T00:15:18+00:00

I began to learn html’n’css, but I’ve encountered one thing that I cannot explain.

  • 0

I began to learn html’n’css, but I’ve encountered one thing that I cannot explain. I have a html file, that has a div which acts like a link (in the application I am setting the div size and want for the whole box to act like a link). I cannot remove the text underline decoration for the text in the div though (Link1 in the Example is always underlined). The selector should be “any div within a link element”, and because the link is red, I think it is correct.

I managed to do this by introducing a special class for removing the underline explicitly (Link2 in the Example is ok), but I would like to have all the menu styles in one place.

The question is, whether can someone explain why the removing deco like this (Link1) does not work. Moreover, I would like to ask if the organization of the menu is a good style, or if I should reorganize the code, e.g: having this for example:

<a href="index.html" class="menuitem"><div>Blabla</div></a>

and the style:

a.menuitem {...}
a.menuitem div {width:...;}

Here is the minimal (non-)working Example:

    <html>
    <head>
    <style>
            a div.menuitem {
              text-decoration: none;
              color: red;
            }
            .remove-under {
              text-decoration: none;
            }
    </style>

    </head>
    <body>
            <a href="./index.html">
                    <div class="menuitem">Link1</div>
            </a>
            <a href="./index.html" class="remove-under">
                    <div class="menuitem">Link2</div>
            </a>
    </body>
    </html>

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:15:19+00:00Added an answer on June 14, 2026 at 12:15 am

    Semantically speaking a <div> should not go inside an <a>. div tags are block elements where anchor tags are inline elements – and block elements should never go inside inline elements. Instead use <span> if you need to stylize something different inline but in your case, additionally, you can add a class to the <a> which would work better.

    Here is your new code:

    <a href="./index.html" class="menuitem">
        Link1
    </a>
    <a href="./index.html" class="remove-under menuitem">
        Link2
    </a>
    

    You can have multiple classes to an element by putting a space, so Link2 has the class “remove-under” and “menuitem”

    Update your CSS to remove the underline:

    .remove-under {
        text-decoration:none;
    }
    

    In order to get your whole a tag to be a link (not just the text) add the follow css for your menuitem class:

    .menuitem {
        display:block;
        width: 100px; 
        height: 50px; /* or whatever your desired width and height */
        background: red; /* to show that the whole anchor will be link, not just text */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I only began learning about web development 3 weeks ago and have grasped html,
I'm trying to learn some html/css/javascript, so I'm writing myself a teaching project. The
trying to learn some html/css and I'm having a problem with fixed position divs.
I recently began doing facebook application development. But it seems that the information out
I have just began recently to learn Haskell, more specifically on the topics of
I have just started to learn how servlets and jsp works but I am
Hi im begin lern liferay and have one problem. I cant send POST in
I began reading the book Code Complete 2nd edition, but stopped reading when I
I began writing an app using declarative_authorization ( http://github.com/stffn/declarative_authorization ) but I'm now wondering
I have recently began using C# to invoke powershell scripts, with some success :)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.