volitics Posted April 21, 2007 Share Posted April 21, 2007 Hello;I've noticed from the Html tutorial that sometimes the front slash is used when using form input tags and at other times the front slash is not used with form input tags.One example from the Html tutorials page has got this:http://www.w3schools.com/tags/tag_input.asp<input type="text" name="fname" value="Mickey" /> // This example uses the front slash.Yet a different page has got an input tag without the front slash:http://www.w3schools.com/html/html_forms.asp<input type="radio" name="gender" value="male"> // This example does not use the front slash.I noticed in one of the above examples they have used the front slash with the <br> tag like this "<br />."Can anybody tell me 1). What is the purpose of the front slash? and 2). When do I need to use the front slash?Thank you in advance. Link to comment Share on other sites More sharing options...
Anders Moen Posted April 21, 2007 Share Posted April 21, 2007 This is HTML: <input type="text" name="adsftgd" value=""> And this is XHTML <input type="text" name="adsgdgf" value="" /> In other words; A space and the slash is XHTML and just this > is HTML if you understand.Like a link should not be like this because it has a starting AND an ending tag (<a></a>), and image has not (<img>)Hope you understood and good luck further Link to comment Share on other sites More sharing options...
falcifer Posted April 21, 2007 Share Posted April 21, 2007 As far as I understood it, all tags require closing tags...but some don't necessarily have a closing tags...e.g.a link has <a ...> link text </a>script has <script> script here </script>and then there are things that don't have closing tags, like <br>, <link>, <img>... but in order to close them you include the />i.e. <br /> instead of <br>It seems to be to be a more formal way of coding HTML and making sure that all tags are closed, even when they don't have a closing tag... Link to comment Share on other sites More sharing options...
Jonas Posted April 21, 2007 Share Posted April 21, 2007 As far as I understood it, all tags require closing tags...but some don't necessarily have a closing tags...e.g.a link has <a ...> link text </a>script has <script> script here </script>and then there are things that don't have closing tags, like <br>, <link>, <img>... but in order to close them you include the />i.e. <br /> instead of <br>It seems to be to be a more formal way of coding HTML and making sure that all tags are closed, even when they don't have a closing tag...It's one of the differences between HTML and XHTML (eXtensible HyperText Markup Language). XHTML is a reformulation of HTML into XML. XML requires "well-formed" documents, that means all tags should be closed, elements should be properly nested (<b><i>text</i></b> as opposed to <b><i>text</b></i>). One of the advantages of this is that you're able to extract elements from the documents and use them in other XML languages. Read more here:http://www.w3schools.com/xhtml/default.aspMain differences between HTML and XHTMLhttp://www.w3schools.com/xhtml/xhtml_html.aspIt's not really difficult going from HTML to XHTML, especially if you picked up good coding habits when learning HTML. Link to comment Share on other sites More sharing options...
falcifer Posted April 22, 2007 Share Posted April 22, 2007 It's one of the differences between HTML and XHTML (eXtensible HyperText Markup Language). XHTML is a reformulation of HTML into XML. XML requires "well-formed" documents, that means all tags should be closed, elements should be properly nested (<b><i>text</i></b> as opposed to <b><i>text</b></i>). One of the advantages of this is that you're able to extract elements from the documents and use them in other XML languages. Read more here:http://www.w3schools.com/xhtml/default.aspMain differences between HTML and XHTMLhttp://www.w3schools.com/xhtml/xhtml_html.aspIt's not really difficult going from HTML to XHTML, especially if you picked up good coding habits when learning HTML.That's cool. Thanks.I guess I always had good habits in HTML anyway... Link to comment Share on other sites More sharing options...
zppblood Posted April 23, 2007 Share Posted April 23, 2007 When using XHTML, you will have a /> when you use a markup tag that doesn't have a closing tag such as the img, br, etc. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now