Home  >  Article  >  Web Front-end  >  Day 6 of building a website using web standards: XHTML code specifications

Day 6 of building a website using web standards: XHTML code specifications

黄舟
黄舟Original
2016-12-19 15:15:271390browse

Before starting formal content production, we must first understand the code specifications of web standards. Understanding these specifications can help you avoid detours and pass code verification as soon as possible.

1. All tags must have a corresponding closing tag

In the past, in HTML, you could open many tags, such as

and

  • without necessarily writing the corresponding

    and
  • to close them. But this is not legal in XHTML. XHTML requires a strict structure and all tags must be closed. If it is a separate unpaired tag, add a "/" at the end of the tag to close it. For example:


    Web Designer


    2. The names of all tag elements and attributes must be in lowercase

    Unlike HTML, XHTML is case-sensitive, and <TITLE> are different tags. XHTML requires that all tag and attribute names must be lowercase. For example: <BODY> must be written as <body>. Mixed case is also not recognized. Usually the attribute name "onMuSEOver" automatically generated by Dreamweaver must also be changed to "onmouseover". </p> <p>3. All xml tags must be nested reasonably </p> <p> Also because XHTML requires a strict structure, all nesting must be in order. In the past, we wrote the code like this: </p> <p><br></p> <p><p> <b></p>/b> </p> That’s it That is, the nesting layer by layer must be strictly symmetrical. <p><br>4. All attributes must be enclosed in quotation marks "" </p> <p> In HTML, you do not need to quote attribute values, but in XHTML, they must be quoted. For example: </p> <p><br></p> <p><height=80></p> <p><br></p> <p>Must be modified to: </p> <p></p> <p></p><height="80"><p><br></p> <p></p>Special cases, you need to set the attribute Worthy To use double quotes, you can use ", and single quotes can be ', for example: <p><br></p> <p></p><alt="say'hello'"><p><br></p> <p></p>5. Put all < and & special symbols Use encoding to represent <p><br/> Any less than sign (<), which is not part of the label, must be encoded as </p><p>& l t; </p><p>Any greater than sign (>), which is not part of the label, must be encoded as <br> & g t ;<p></p>Any ampersand (&) that is not part of the entity must be encoded as <p><br>& a m p;</p> <p> Note: There are no spaces between the above characters </p> <p>6. Assign a value to all attributes</p>. <p> XHTML stipulates that all attributes must have a value, and if there is no value, it will repeat itself. For example: </p> <p></p> <p></p><td nowrap><p></p><input type="checkbox" name="shirt" value="medium" checked> "><p></p> <p></p> <p>7. Do not use "--" in comment content</p> <p> "--" can only occur at the beginning and end of XHTML comments, that is, they are no longer valid in the content. For example The following code is invalid: </p> <p><br></p> <p><!--Comment here----------Comment here--></p> <p></p> <p><br> Replace the interior with equal signs or spaces The dotted line. </p> <p></p> <p><br><!--Comments here============Comments here--></p> <p></p> <p></p>Some of the above specifications look strange. But all this is to make our code have a unified and unique standard to facilitate future data reuse. <p><br> The above is the content of Day 6 of building a website using Web standards: XHTML code specification. For more related content, please pay attention to PHP. Chinese website (www.php.cn) </p> <p></p> <p></p></div><div class="nphpQianMsg"><div class="clear"></div></div><div class="nphpQianSheng"><span>Statement:</span><div>The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn</div></div></div><div class="nphpSytBox"><span>Previous article:<a class="dBlack" title="Day 5 of building a website using web standards: other settings in the head area" href="http://m.php.cn/faq/345362.html">Day 5 of building a website using web standards: other settings in the head area</a></span><span>Next article:<a class="dBlack" title="Day 5 of building a website using web standards: other settings in the head area" href="http://m.php.cn/faq/345364.html">Day 5 of building a website using web standards: other settings in the head area</a></span></div><div class="nphpSytBox2"><div class="nphpZbktTitle"><h2>Related articles</h2><em><a href="http://m.php.cn/article.html" class="bBlack"><i>See more</i><b></b></a></em><div class="clear"></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-6t+ed+2i-1n-4w" data-ad-client="ca-pub-5902227090019525" data-ad-slot="8966999616"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><ul class="nphpXgwzList"><li><b></b><a href="http://m.php.cn/faq/348757.html" title="Summary of Html knowledge" class="aBlack">Summary of Html knowledge</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/faq/348804.html" title="How to learn HTML quickly" class="aBlack">How to learn HTML quickly</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/faq/348873.html" title="The difference between html xhtml xml" class="aBlack">The difference between html xhtml xml</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/faq/348884.html" title="The difference between src and href attributes" class="aBlack">The difference between src and href attributes</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/faq/348902.html" title="About HTML5 and CSS replacement use" class="aBlack">About HTML5 and CSS replacement use</a><div class="clear"></div></li></ul></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="5027754603"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><footer><div class="footer"><div class="footertop"><img src="/static/imghwm/logo.png" alt=""><p>Public welfare online PHP training,Help PHP learners grow quickly!</p></div><div class="footermid"><a href="http://m.php.cn/about/us.html">About us</a><a href="http://m.php.cn/about/disclaimer.html">Disclaimer</a><a href="http://m.php.cn/update/article_0_1.html">Sitemap</a></div><div class="footerbottom"><p> © php.cn All rights reserved </p></div></div></footer><script>isLogin = 0;</script><script type="text/javascript" src="/static/layui/layui.js"></script><script type="text/javascript" src="/static/js/global.js?4.9.47"></script></div><script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script><link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='/static/js/viewer.min.js?1'></script><script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script><script>jQuery.fn.wait = function (func, times, interval) { var _times = times || -1, //100次 _interval = interval || 20, //20毫秒每次 _self = this, _selector = this.selector, //选择器 _iIntervalID; //定时器id if( this.length ){ //如果已经获取到了,就直接执行函数 func && func.call(this); } else { _iIntervalID = setInterval(function() { if(!_times) { //是0就退出 clearInterval(_iIntervalID); } _times <= 0 || _times--; //如果是正数就 -- _self = $(_selector); //再次选择 if( _self.length ) { //判断是否取到 func && func.call(_self); clearInterval(_iIntervalID); } }, _interval); } return this; } $("table.syntaxhighlighter").wait(function() { $('table.syntaxhighlighter').append("<p class='cnblogs_code_footer'><span class='cnblogs_code_footer_icon'></span></p>"); }); $(document).on("click", ".cnblogs_code_footer",function(){ $(this).parents('table.syntaxhighlighter').css('display','inline-table');$(this).hide(); }); $('.nphpQianCont').viewer({navbar:true,title:false,toolbar:false,movable:false,viewed:function(){$('img').click(function(){$('.viewer-close').trigger('click');});}}); </script></body></html>