HTML empty tags

There are many empty span tags in my code, etc. Due to CSS image replacement methods. They trigger an HTML validation warning.

Should I take care?

+7
html validation
source share
7 answers

Warning is not an error. This is just a reminder that you need to improve something.

+1
source share

I agree with @Gumbo, but with a lot of warnings that don't matter, you can hide the ones you need to pay attention to. If you can put something in the gap that gets rid of the warning but doesn't violate your user interface, you should at least think about it.

+10
source share

I did part of the validation of my workflow because it helps me to make the wrong mistakes. And although I do not consider empty elements as a problem, it negates some of the validator usage values ​​if I have to mentally parse the list of warnings each time and decide whether the warning is important or not. Therefore, I try to ensure that my pages are error-free and error-free, so that a quick look at the HTML Validator icon in the Firefox status bar only changes when there is a real problem. To this end, I keep the empty elements "non-empty" by inserting an empty comment.

<span><!-- --></span> 

(At least this works with the Tidy validator.)

Now, to say the least, I do not think that this is necessary at all for many situations. It makes perfect sense to think that adding eight extra characters to your code just to avoid a validator warning is ridiculous. But it works for me.

+9
source share

You should consider page behavior for things like screen readers. It is usually customary to impose a few words describing the image in the tag, which are then hidden when replacing the images.

See CSS Zen Garden for examples, such as H1, with replaceable text in CSS images.

This will improve not only the availability of your site, but also the ability to search.

+8
source share

An "empty" tag has a very specific definition in HTML:

 <span/> 

against

 <span></span> 

The first is not allowed HTML 4.0 Strict DTD , so it must be marked with a validator. The only tags that can use the previous syntax are those defined as "NULL" in the DTD (for example, <br> ).

The second form is valid HTML and is not tagged with a W3C validator .

Therefore, I must assume that either (1) your validator is broken, or (2) you are using the tag incorrectly.

+2
source share

I assume that if bandwidth was a problem, these empty tags could be reviewed to make sure you can make them appear in general.

+1
source share

Eric Meyer also says empy tags are bad, semantically.

A warning does not mean that it is wrong, but to say that it can or sometimes should be better.

In the same way

 if("value"==variable) 

better than

 if(variable=="value") 
0
source share

All Articles