Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid location of tag <div> in JSP

Tags:

html

css

jsp

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>
like image 599
salma Avatar asked Apr 29 '15 20:04

salma


1 Answers

<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.

like image 152
Bruno Ribeiro Avatar answered Oct 28 '22 18:10

Bruno Ribeiro