is it common now if you have a div which is not going to contain anything to be done like this
instead of thisCode:<div id="" />
Code:<div id=""> </div>
is it common now if you have a div which is not going to contain anything to be done like this
instead of thisCode:<div id="" />
Code:<div id=""> </div>
Not if you want it to validate.
If there is no CSS involved, then there is no need for empty id either. An empty div, while not exactly bad mark up will through a warning though. It is best to use as such:
Code:<div> </div>
{CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
Follow Me on Twitter: @InkingHubris
PHP Code:$result = mysql_query("SELECT finger FROM hand WHERE id=3");
echo $result;
/>
is not any part of HTML.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
There is CSS but no text or content form the actual html side of things
Well if you have CSS set up for an empty div, then you can use the class or ID still the same
Code:<div id="empty"> </div>
{CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
Follow Me on Twitter: @InkingHubris
PHP Code:$result = mysql_query("SELECT finger FROM hand WHERE id=3");
echo $result;
There is nothing wrong with:
or with:HTML Code:<div></div>
or with:HTML Code:<div id="whatever"></div>
regardless of if 'whatever' is defined or not. If you want no class or id associated with the empty tag, use the first option. The only reason that you would need anything in there would be if you are going to use DOM level 2 javascript to replace it. Like:HTML Code:<div class="whatever"></div>
For simple layout purposes though, an empty tag is fine, and may be styled however you like.Code:documentGetElementById('whatever').firstChild.nodeValue='Hello World';
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
technically.. no there isn't, except that with correct validating code it does produce a warning. empty elements such as <p> or <div> are not Strict INvalid, but the warning is there for a reason. Adding a space to the div does nothing to the layout and eliminates the warningThere is nothing wrong with:![]()
{CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
Follow Me on Twitter: @InkingHubris
PHP Code:$result = mysql_query("SELECT finger FROM hand WHERE id=3");
echo $result;
This validates (W3c - verbose output):
No warning. Excuse the id, I picked it before I read your post. Another thing, a space shouldn't be a layout problem (except perhaps in IE 6 - maybe even 7 - line height is often given even when there is only a space), but a nbsp entity will be unless the style is set to display:none;. An empty div with its clear property set can often be very advantageous in dealing with prior floats in a container with background, in which case its display property should not be none.Code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <div id="bull"></div> </body> </html>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
My apologies.. I should have been more clear. HTML 4.01 Strict valid coding does NOT discern empty elements. It is the mark up validation WITH Tidy that will through the error ("Trimming empty <div>" )
As stated, it isn't a problem, but some people care about such things, which is why I mentioned that adding the space will eliminate all of that.![]()
{CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
Follow Me on Twitter: @InkingHubris
PHP Code:$result = mysql_query("SELECT finger FROM hand WHERE id=3");
echo $result;
AFAIK, Tidy isn't a validator. It's a tool for cleaning up your code, right? Empty tags can often be left over from some content that got moved or removed. If that's the only reason for them being there, they should go. I imagine Tidy warns about them for that very reason, and that it is only a warning because there could be a valid reason (as mentioned in my previous post) for their being there.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Bookmarks