Invalid location of tag <div> in JSP

19,158

<div> isn't valid inside an <a>.

In HTML 4.1 specification that <a> elements may only contain inline elements and <div> is a block element, so it may not appear inside an <a>.

So, instead:

<a href="#">
    <span class="ca-icon">A</span>

    <div class="ca-content">
        <h2 class="ca-main">Exceptional Service</h2>
        <h3 class="ca-sub">Personalized to your needs</h3>
    </div>

</a>

Use:

<a href="#">
    <span class="ca-icon">A</span>
</a>
<div class="ca-content">
    <h2 class="ca-main">Exceptional Service</h2>
    <h3 class="ca-sub">Personalized to your needs</h3>
</div>

Or something else that represents what you need, but always with <div> outside <a>

Take a look at "The a element" in HTML 5 specification, may help you.

Share:
19,158
salma
Author by

salma

Updated on August 01, 2022

Comments

  • salma
    salma almost 2 years

    I insert some code HTML in my jsp page: acceuil.jsp, but I'm getting an error in my tag <div class="ca-content">. It shows me that it's an invalid location. (the ca-content is referring to a class in my stylesheet).

    I tried to disable the HTML validator but I'm still having the same error.

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/acceuil.css" />
        <title>Insert title here</title>
    </head>
    <body>
        <ul class="ca-menu">
            <li>
                <a href="#">
                    <span class="ca-icon">A</span>
    
                    <div class="ca-content">
                        <h2 class="ca-main">Exceptional Service</h2>
                        <h3 class="ca-sub">Personalized to your needs</h3>
                    </div>
    			
                </a>
            </li>
    
        </ul>
    </body>
    </html>