Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] Do HTML anchors need to be closed?

Started by ManaStone Nov 15, 2009 at 1:07 PM 3 replies 600+ views
Original Post
ManaStone
ManaStone
Is there anything wrong with not closing an anchor like this as opposed to closing it like this?

 Title 1
[Paragraph body]

It appears to work fine with Firefox. Are there any general problems with not closing an anchor?
-----------------------------Download my real time 3D RPG.
swiftcoder
swiftcoder
Quote:
Original post by ManaStone
Are there any general problems with not closing an anchor?
the whole block is going to be subject to the a tag, as far as CSS styles are concerned (try it - apply a CSS style of yellow to all a tags, and see if the paragraph changes colour).

The reason you aren't noticing this, is that <a name=""> tags don't have any style applied by default.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
Stani R
Stani R
You should strive to write standards-conforming html, which means you should close all tags and put all attribute values in quotation marks, and you should not close outer tags inside inner tags (for instance ). The fact that browsers can be good at working around malformed code is not really a license to mutilate your code on purpose. It might break in another browser or a screen reader or xml editor.

Edit: doh, didn't think of CSS. -_-;;;
kryat
kryat
short answer: Yes. You are required to close tags

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.