Danh mục

Developing Large Web Applications- P7

Số trang: 10      Loại file: pdf      Dung lượng: 320.28 KB      Lượt xem: 11      Lượt tải: 0    
Hoai.2512

Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Developing Large Web Applications- P7:This book presents a number of techniques for applying established practices of goodsoftware engineering to web development—that is, development primarily using thedisparate technologies of HTML, CSS, JavaScript, and server-side scripting languages.Whereas there are many books on how to use languages, how to use libraries, and howto approach software engineering, this is the first book to codify many of the techniquesit presents. These techniques will make the components of your own web applicationsmore reusable, maintainable, and reliable....
Nội dung trích xuất từ tài liệu:
Developing Large Web Applications- P7Don’t confuse the id attribute with the name attribute. In various form inputs, thename attribute lets you give names to input values; these names are passed along withthe values for scripts on the server side.Conventions for NamingThere are a lot of opinions about naming conventions for IDs, classes, and names, buteveryone can agree that establishing some sort of convention is important. In large-scale HTML, a good naming convention is key to modularity. One convention, dem-onstrated earlier in Example 3-3, is to use short groups of three to six characters fornaming (e.g., nwcrev is the ID for the New Car Reviews module). From here, you canappend other name segments of three or four characters to create further qualifiednames for use deeper within the module (e.g., nwcreveml for the id and name attributesof the email address text field).Using fully qualified names like this promotes modularity because you can be assuredthat anywhere you use this module, its names will not conflict with those used by othermodules. For example, if you were to place the New Car Reviews module on a pagewith another module that also contained a similar form input field for an email address,this naming convention would ensure that the inputs of the two modules would bepassed to the server-side script with different names.Because using short, augmentable name segments is compact and works well, it’s theconvention that we employ throughout this book. That said, the exact convention isnot what is important here; whatever conventions you prefer, establishing a system ofunique qualification that ensures modularity is the key.XHTMLFor quite some time, HTML has implied HTML 4.01, but browsers have been veryforgiving of code that did not meet precisely with this specification. In fact, many egre-gious transgressions are politely rendered by the browsers in a reasonably elegant way.That said, this forgiving attitude by browsers has been a double-edged sword. On theone hand, it plays an essential role in ensuring that older documents can survive on theWeb with little or no modification. On the other hand, it gives web developers a lot ofroom to be sloppy. XHTML establishes a more rigorous definition of HTML that for-mally helps web developers alleviate some of this sloppiness.Benefits of XHTMLXHTML 1.0, the latest version of XHTML from the W3C to advance past the workingdraft stage, is a reformulation of HTML 4.01 in XML 1.0. This reformulation providesadditional rigor and formality that earlier versions of HTML were never intended tohave. Because XHTML conforms to XML, it offers web developers several benefits. XHTML | 41First and foremost, XHTML’s strictness results in cleaner, more consistent code thatpromotes better maintainability and reliability. Next, XHTML is readily viewed, edited,and validated with standard XML tools. In addition, XHTML can utilize applicationsthat rely upon either the HTML DOM or the XML DOM. Finally, XHTML is morelikely to interoperate within various XHTML environments in the future shouldXHTML continue to advance. Since XHTML can be written to operate in older brows-ers as well as in XHTML-conforming browsers, there are few reasons not to start writingHTML using this higher standard.XHTML GuidelinesFortunately, it is relatively easy to make the HTML that we write conform to the higherstandards of XHTML. The examples of HTML in this chapter, as well as in the rest ofthe book, are actually XHTML, for the most part. Most HTML is compatible withXHTML, but there are a few guidelines that you need follow to ensure your codeconforms to XHTML while continuing to render properly in older and XHTML-conforming browsers alike. A list of these guidelines is presented below.Proper nesting of tagsIn XHTML, tags must be nested in such a way that tags are closed in the exact reverseorder that they were opened. For example, Example 3-3 contains the following, wherethe tags are properly nested: 2009 Nissan Altima (from $19,900).Consider, in contrast, the following example, where the strong tag is closed before theem tag. This does not conform to XHTML: 2009 Nissan Altima (from $19,900).End tags and empty tagsIn XHTML, every tag must have a corresponding end tag. In HTML, web developersfrequently leave off closing tags for elements such as list items and paragraphs becausebrowsers can infer where these tags should be closed. In XHTML, you must providethe end tags explicitly. Example 3-3 includes the following text, where we have correctlyclosed all list items: 2009 Toyota Prius (from $22,000). Read the review42 | Chapter 3: Large-Scale HTML 2009 Nissan Altima (from $ ...

Tài liệu được xem nhiều: