简体   繁体   中英

CSS HTML <a> </a> tags appearing on Nav bar

I have an issue that I have not experienced before and I am hoping to get some information on it. I have a nav bar that is displayed at the top on a webpage and for some reason when the code is run, the browser adds some a>/a> tags which cause my links to have some... disposition themselves. I am hoping to find out how to stop this from happening. Below is an example of the code.


My code:

<nav>   
    <ul id="LevelMenu">
        <?php if($currentuser['userlevel']==0) { ?>
        <li><a href="register.html">Register New Account</a></li>
        <?php } else { 
                if($currentuser['userlevel']==1) { ?>
        <li><a href="inactive.php">Account Panel<a></li>
                <?php } else { ?>
        <li><a href="user.php">Account Panel<a></li>
            <?php if($currentuser['userlevel']>2) { ?>
        <li><a href="admin.php">Administration</a></li>
            <?php }
                } ?>
        <li><a href="php/logout.php">Log Out</a></li>
        <li><a href="addarticle.php" id="addarticle">Add Article</a></li>
        <?php } ?>
    </ul>
</nav>

Code on Browser:

    <nav>
    <ul id="LevelMenu">
                <li>
                  <a href="user.php">Account Panel</a>
                    <a></a> 
                </li>
                    <a></a>
                <li>
                    <a></a>
                  <a href="index.php">Home</a>
                </li>
                <li>
                  <a href="admin.php">Administration</a>
                </li>
                <li>
                  <a href="index.php">Home</a>
                </li>
                <li>
                  <a href="php/logout.php">Log Out</a>
                </li>
                <li>
                  <a href="addarticle.php" id="addarticle">Add Article</a>
                </li>
            </ul>
</nav>

Result:

在此处输入图片说明

This line:

<li><a href="inactive.php">Account Panel<a></li>

You're not closing the <a> , but opening a new one. Fix:

<li><a href="inactive.php">Account Panel</a></li>

Same problem with:

<li><a href="user.php">Account Panel<a></li>

You are Not Closing Your Anchor Tag.
Correct format would be <a href = "" ></a>

And You are Doing it like this:

  <li><a href="inactive.php">Account Panel<a></li>  

Instead Do This:

  <li><a href="inactive.php">Account Panel</a></li> 

And Same with all other Places where you are doing the same.

Refer To The W3 Documentation for further information on anchor tag.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM