XHTML Block Element in an Inline Element

This is a discussion on "XHTML Block Element in an Inline Element" within the Web Page Design section. This forum, and the thread "XHTML Block Element in an Inline Element are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 3rd, 2004, 18:37
Junior Member
Join Date: Jul 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
XHTML Block Element in an Inline Element

I created the following to make a navigation sidebar.



Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>
<title>navigation bar problem</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<style type="text/css">

.div_nav { /* navigation bar */
width: 100px;
float: left;
border-right: none;
background-color: black;
}

.navLink {
padding: 2px;
padding-left: 5px;
border-left: 2px solid black;
border-bottom: 1px solid black;
background-color: #3C2A36 !important;
font: 10px "Lucida Sans Unicode", Verdana, Arial, Sans-serif; color: #F0F0F0;
text-decoration: none;
text-align: left;
cursor: pointer;
}

.navOver {
padding: 2px;
padding-left: 5px;
border-left: 2px solid black;
border-bottom: 1px solid black;
background-color: #3C2A36 !important;
font: bold 10px "Lucida Sans Unicode", Verdana, Arial, Sans-serif; color: #F0F0F0;
text-align: left;
text-decoration: none;
cursor: pointer;
}

</style>

</head>

<body>

<div class="div_nav">
<div style="border-top: 2px solid black;" class="navLink" onmouseover="this.className='navOver'" onmouseout="this.className='navLink'">home</div>
<div class="navLink" onmouseover="this.className='navOver'" onmouseout="this.className='navLink'">site</div>
<div class="navLink" onmouseover="this.className='navOver'" onmouseout="this.className='navLink'">blog</div>
<div class="navLink" onmouseover="this.className='navOver'" onmouseout="this.className='navLink'">about</div>
<div class="navLink" onmouseover="this.className='navOver'" onmouseout="this.className='navLink'">galleria</div>
<div class="navLink" onmouseover="this.className='navOver'" onmouseout="this.className='navLink'">link</div>
<div style="border-bottom: 2px solid black" class="navLink" onmouseover="this.className='navOver'" onmouseout="this.className='navLink'">contact</div>
</div>

</body>

</html>

<blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote">

Line 51, column 175: document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag

...onmouseout="this.className='navLink'">home</div></a>

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 "

" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">


Now the problem is that this does not validate for XHTML 1.0 Transitional. The problem would be the <div> in between the <a></a>. I understand that I cannot have a block level element like the <div> in an inline element like the <a>. However, I can't think of any other way to get the effect I want. I suspect I might need to use javascript, but I'm hoping not to go there cause I know nothing about it.

I'm hoping someone can give me a XHTML solution to the problem! Thanks for any help!

  #2 (permalink)  
Old Jul 3rd, 2004, 18:54
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
IMO don't bother trying to fix that. Check it in the different browsers, if it looks right don't worry about the validation.

But, have you tried simply putting the links inside the divs?
  #3 (permalink)  
Old Jul 3rd, 2004, 18:56
Junior Member
Join Date: Jul 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, and unfortunately, if you look at the before and after pages using your solution, it doesn't look as good after as it does before.
  #4 (permalink)  
Old Jul 3rd, 2004, 19:09
Junior Member
Join Date: Jul 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks everybody. I got it to work.
  #5 (permalink)  
Old Jul 4th, 2004, 10:45
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
What is the point of having all that inline CSS code, when you are using a <style> block?

Why dont you move all the inline code into the style part of the page?

Inline CSS is a bad habit to get into, and just makes for serious code bloat imho.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #6 (permalink)  
Old Jul 4th, 2004, 17:46
Up'n'Coming Member
Join Date: Oct 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jamslam
Yea Rob you are completely correct. I still find myself using the style attribute every now and then for little things because I get lazy... But then I have a whole bunch of little things, and it doesn't look too good
  #7 (permalink)  
Old Jul 27th, 2004, 10:15
New Member
Join Date: Oct 2003
Location: United Kingdom
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
can you not achieve the same effect using a:hover to change the style thus removing all the div tags within the a tags completely
Closed Thread

Tags
xhtml, block, element, inline

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
help on removing element using yui shotokan99 JavaScript Forum 1 Aug 31st, 2007 13:42
How To Fix <TD> Element Size? ivan Web Page Design 6 Dec 11th, 2005 18:43
using params in xsl IF element zzqproject Other Programming Languages 0 Nov 21st, 2005 23:12


All times are GMT. The time now is 08:52.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43