Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Location
    Ohio
    Posts
    286
    Thanks
    7
    Thanked 9 Times in 9 Posts

    Invalid line break?

    When I attempt to validate my code with XHTML strict, I receive errors on line breaks and I am not sure why. I have been using <br /> with XHTML transitional for the longest time with no problems and I am certain that I have used it in the past with a strict doctype.

    This is the error I am receiving:
    Error Line 77 column 5: document type does not allow element "br" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag.

    <br />

    The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

    One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").
    I think that there must be something else wrong with my code, but I cannot find it. Can anyone tell me why I am getting this error with <br />?

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html>
    <!-- all html written by Dorienne Smith -->
    <head>
    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="stylesheet" href="home.css" type="text/css" />
     
    <meta name="keywords" content="dorienne smith, calvin and hobbes, calvin, hobbes, bill watterson, comics, downloads, pictures, images, gifs, books, facts, poetry" />
    <meta name="description" content="Midnight Calvin - For those whose midnight pastime is re-discovering the beloved comic Calvin and Hobbes" />
    <meta name="owner" content="kaitco@doriennesmith.com" />
    <meta name="author" content="Dorienne Smith" />
    <meta http-equiv="content-language" content="English" />
    <meta name="rating" content="General" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    <title>Poetry - Midnight Calvin -- Dorienne Smith.com</title>
    
    <style type="text/css">
    html, body {
    	color: #fff; 
    	background: #000; 
    	font-family: Arial, Helvetica, sans-serif; 
    	font-size: 18px;
    	}
    
    a {
    	color: #fff;
    	}
    
    a img {
    	border-style: none;
    	}
    
    ul {
    	list-style: none; 
    	font-size: 12px; 
    	text-align: center;
    	}
    	
    li {
    	display: inline;
    	}
    
    h1 {
    	text-align: center;
    	}
    
    dl {
    	padding: 1em 0;
    	}
    	
    dt {
    	font: normal large Verdana, Arial, Helvetica, sans-serif;
    	}
    
    dd {
    	font: normal small Tahoma, Arial, Helvetica, sans-serif;
    	}
    
    p {
    	font: medium, Arial, Helvetica, sans-serif;
    	padding: 0;
    	margin: 0;
    	}
    
    #footer {
    	text-align: center;
    	}
    </style>
    
    </head>
    
    <body>
    <?php include ("nav.php"); ?>
    <h1><a id="top"><img src="images/players/newpoetry.gif" alt="Poetry" /></a></h1>
    <br />
    <ul>
    	<li><a href="#alien">Alien Brain Drain</a></li>
    	<li><a href="#mind">Exploring Mind</a></li>
    	<li><a href="#mum">My Mom and Dad</a></li>
    	<li><a href="#night">Nauseous Nocturne</a></li>
    	<li><a href="#sixmas">Six Days 'Til Christmas</a></li>
    	<li><a href="#trex">The Tyrannosaur</a></li>
    	<li><a href="#water">Water-Stealing Blue Collar Work</a></li>
    	<li><a href="#eve">Christmas Eve</a></li>
    </ul>
    
    <dl>
    	<dt><a id="alien">Alien</a> Brain Drain</dt>
    		<dd>While lying on my back to make</dd>
    		<dd>An angel in the snow</dd>
    		<dd>I saw a greenish graft appear!</dd>
    		<dd>A giant UFO!</dd>
    		<dd>&nbsp;</dd>
    		<dd>A strange, unearthly hum it made!</dd>
    		<dd>It hovered overhead!</dd>
    		<dd>And aliens were moving 'round</dd>
    		<dd>In view ports glowing red!</dd>
    		<dd>&nbsp;</dd>
    		<dd>I tried to run for cover, but</dd>
    		<dd>A hook that they had low'r'd</dd>
    		<dd>Snagged me by my overcoat</dd>
    		<dd>And hoisted me aboard.</dd>
    		<dd>&nbsp;</dd>
    		<dd>Even then, I tried to fight</dd>
    		<dd>And though they numbered many,</dd>
    		<dd>I poked them in their compound eyes</dd>
    		<dd>And pulled on their antennae!</dd>
    		<dd>&nbsp;</dd>
    		<dd>It was no use! They dragged me to </dd>
    		<dd>A platform, tied me up,</dd>
    		<dd>And wired to my cranium</dd>
    		<dd>A fiendish suction cup!</dd>
    		<dd>&nbsp;</dd>
    		<dd>They turned it on and current coursed</dd>
    		<dd>Across my cerebellum</dd>
    		<dd>Coaxing from my brain tissue</dd>
    		<dd>The things I wouldn't tell 'em!</dd>
    		<dd>&nbsp;</dd>
    		<dd>All the math I ever learned,</dd>
    		<dd>The numbers and equations,</dd>
    		<dd>Were mechanic'ly removed in this</dd>
    		<dd>Brain-draining operation!</dd>
    		<dd>&nbsp;</dd>
    		<dd>My escape was an adventure.</dd>
    		<dd>(I won't tell you what I did.)</dd>
    		<dd>Suffice to say, I cannot add,</dd>
    		<dd>So ask some other kid.</dd>
    </dl>
    <p>Back to the <a href="#top">top</a></p>
    <div id="footer">
    	<p><a href="calvinbuy.php"><img src="images/newcalbuy.gif" alt="Buy Calvin and Hobbes" /></a></p>
    	<?php include ("bar.php"); ?>
    	<p><img src="/cgi-sys/Count.cgi?df=calvin.dat|display=Counter|ft=6|md=5|frgb=100;139;216|dd=C" alt="counter" /></p>
    </div>
    </body>
    
    </html>

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    What the error message is basically saying is that you can't have a <br /> tag out by itself, it needs to be inside one of the tags listed in the first sentence of the error message.

    The usage you are using might be allowed under a transitional doc type so that might be why you haven't really ran into this problem before.
    OracleGuy

  • #3
    Regular Coder
    Join Date
    Dec 2005
    Location
    Ohio
    Posts
    286
    Thanks
    7
    Thanked 9 Times in 9 Posts
    Wow! I never knew a line break could not stand by itself. I guess you learn something new everyday. Thanks!

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Though I don't think you are using the break return properly. In the way you are using it you should be using a bottom margin on the h1 tag before it instead.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    Regular Coder
    Join Date
    Dec 2005
    Location
    Ohio
    Posts
    286
    Thanks
    7
    Thanked 9 Times in 9 Posts
    Yeah, I know it is better to just change the margins to get the effect that was created by the line break, but I wanted to know what the problem was and in the process learned how <br /> should and should not be used.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •