HTML - CL2 Flashcards
Design Patterns:
- HTML Structure
- XHTML
- DOCTYPE
- Header Elements
- Conditional Stylesheet Structural Block Elements
- Terminal Block Elements
- Multi-purpose Block Elements Inline Elements
- Class and ID Attributes
• HTML Structure shows how HTML elements work together to create a document.
• XHTML shows how to mark up a document with valid XHTML. It also points out
why using valid XHTML makes styling with CSS more reliable.
• DOCTYPE shows how to use document types to validate the way documents are
coded, and it explores what document types work best for CSS and HTML.
• Header Elements shows how to create metadata about a document and how to
link a document to supporting documents and related documents.
• Conditional Style Sheet shows how to load a style sheet to fix problems unique to
Internet Explorer.
• Structural Block Elements shows how to create structural meaning in a
document.
• Terminal Block Elements shows how certain blocks have semantic meaning
because they contain content instead of other blocks.
• Multi-purpose Block Elements shows how certain elements can be used for
block structure and semantic meaning.
• Inline Elements shows how styles can bring out the meaning of semantic
markup.
• Class and ID Attributes shows how CSS relies on class and id attributes to select
elements. It also shows how the class attribute can add meaning to an element.
• HTML Whitespace shows how to make whitespace work for you instead of
against you.
HTML Structure
Problem
You want to know how HTML elements work together to create an HTML document.
Solution
HTML is a strict hierarchical nesting of elements. Elements may be nested within each
other, but they cannot overlap each other. HTML organizes elements into three major
categories: structural, block, and inline elements.
The core structural elements are , , and . Information about a
document goes in and document content goes in . Header elements are
covered in the Header Elements design pattern discussion.
There are three types of block elements: structural, multi-purpose, and terminal. These are
covered in the following design pattern discussions: Structural Block Elements, Terminal
Block Elements, and Multi-purpose Block Elements.
There are three major types of inline elements: semantic, flow, and inline-block. These are
covered in the Inline Elements design pattern discussion.
Pattern
HTML Core Structure
METADATA
CONTENT
Example
The example contains the simplest expression of each common HTML element.
The concept behind the element is that it represents an external resource, which,
depending on the type of the resource, will be treated as an image, as a nested browsing
context, or as an external resource to be processed by a plug-in. Different browsers have
varying support for this element. The HTML5 specification defines several attributes like
data , type , name , etc.
Related to
Header Elements, Structural Block Elements, Terminal Block Elements, Multi-purpose Block
Elements, Inline Elements, Structural Meaning, Visual Structure (Chapter 13)
XHTML
Problem
You want to create a document using XHTML.
Solution
The HTML5 specification defines an abstract language for describing documents and applications, and
some APIs for interacting with what is known as the “DOM HTML”, or “the DOM” for short. There are
various concrete syntaxes for the foregoing language, and two are HTML and XHTML.
HTML (or HTML5) is the format suggested for most authors. It is compatible with most legacy web
browsers. If a document is transmitted with an HTML MIME type, such as text/html, then it will be
processed as an HTML document by web browsers.
XHTML (or XHTML5) is an application of XML. When a document is transmitted with an XML MIME
type, such as application/xhtml+xml, then it is treated as an XML document by web browsers, to be
parsed by an XML processor. Authors are reminded that the processing for XML and HTML differs; in
particular, even minor syntax errors will prevent a document labeled as XML from being rendered fully,
whereas they would be ignored in the HTML syntax.
Essentially an XHTML5 page is a simple HTML5 document that has the following:
HTML doctype/namespace: The < !DOCTYPE html > definition is optional, but it would be useful for
preventing browser quirks mode.
XHTML well-formed syntax
XML MIME type: application/xhtml+xml; this MIME declaration is not visible in the source code, but it
would appear in the HTTP Content-Type header that could be configured on the server.
Default XHTML namespace: < html xmlns=”http://www.w3.org/1999/xhtml” >
XHTML is case-sensitive, and HTML is case-insensitive. XHTML requires all tags and attributes to be
lowercase (e.g., instead of ). CSS selectors are case-sensitive in XHTML! In XHTML, the
case of class or id values must match before they will be selected by CSS! For example, the selectors
#test and *.test select <h1 class="TEST"> in HTML, but not in XHTML. For this
reason, I recommend always using lowercase attribute values and tag names in XHTML and CSS.
XHTML requires the tag to include the xmlns attribute with the value of
“http://www.w3.org/1999/xhtml” . XHTML requires the xml:lang attribute to be present each time
the HTML lang attribute is used, such as xml:lang=”en” lang=”en”.
XHTML requires all elements to have start and end tags and all attributes to be enclosed in quotes and
to have a value. HTML does not.
HTML lets you omit the start tags for , , , and . HTML lets you omit end
tags for , , , </h1><p> , </p><li> , <dt> , </dt><dd> , , , and . A browser implies their
presence in HTML. In XHTML, a document will not validate if these tags are omitted.
HTML prohibits end tags for elements that must always be empty: , , , <br></br> , <hr> ,
, <img></img> , , , , and . XHTML requires end tags for all elements.
Thus, a valid XHTML document containing one of these elements can never be a valid HTML document
and vice versa. There is a compromise that works in HTML browsers because they do not require
documents to be valid HTML. You can use the XML shorthand notation for an empty element as long as
it includes a space before the closing slash and less-than sign. This works as follows: , , , <br></br> , <hr> , , <img></img> , , , , and . You should use a separate closing tag for all other empty elements, such as <span></span> .
Advantages
It has been argued that the strict coding requirements of XHTML identify the structure of a document
more clearly than HTML. In HTML, a browser assumes the location of a missing end tag to be the start
tag of the next block element. In the example, <br></br> is rendered after the paragraph in the XHTML
document and as part of the paragraph in the HTML document. This is why there is an extra line of
whitespace in the XHTML part of the example.
A valid and unambiguous structure is essential when you use CSS to style a document because CSS
selectors select elements based on their structure. For this reason, some developers might prefer
XHTML for their projects.
Related to
DOCTYPE
DOCTYPE
Alias
Metadata Declaration
Problem
You want to declare the type of your document so you can validate it against a Document Type
Definition (DTD). You want to ensure your document is valid. You want to ensure web
browsers follow the same rules in rendering your document.
Solution
The prolog identifies the type and version of HTML or XHTML in which the
document is coded. In technical terms, specifies the type of document and the
DTD that validates the document. The W3C provides a free online service at
http://validator.w3.org/ that you can use to validate your documents.
All HTML and XHTML code should be validated. This verifies the code contains no coding
errors. If there are errors, CSS selectors may fail to select elements as expected or may even
select elements unexpectedly.
There are benefits to using XHTML. Validated XHTML documents are well formed and have
unambiguous structure. You can also use XSLT (Extensible Stylesheet Language) and XQUERY
(XML Query Language) processors to extract content and rearrange documents.
In the HTML4 era, there were two additional varieties of DOCTYPEs: strict and transitional.
Strict removes all presentational elements and attributes, and transitional allows them. I do
not recommend presentation elements and attributes, but the strict DOCTYPE may be too
strict for some needs. For example, it prohibits the start attribute in <ol> and the value
attribute in <li> , which are the only available means to control the numbering of an ordered
list. The strict DOCTYPE also prohibits .
Most important to CSS, browsers use to determine how closely they will follow the
CSS standard when they render the document. There are two basic modes: quirks and
standards. In quirks mode, browsers do not follow the CSS standard, which makes this mode
undesirable for styling with CSS. In standards mode, they follow the CSS specification.
To complicate matters, Internet Explorer in strict mode violates a part of the CSS spec by not
aligning images in table cells to the baseline. It does this to remove the baseline space below
images so that sliced images in tables work as expected. The other major browsers have a third
mode called almost-standards mode that emulates this nonstandard behavior.
The standards mode of Internet Explorer and the almost-standards mode of the other major
browsers are the most compatible modes. There are two main declarations that
trigger this level of compatibility: one for XHTML and one for HTML. They are listed in the
DOCTYPE code example. You can find a complete list of DOCTYPEs at
http://hsivonen.iki.fi/doctype/ .
Location
must be the first item in an HTML document. There must be only one
per document. You must not precede this DOCTYPE with an XML declaration, such as , or Internet Explorer 6 will trigger quirks mode.
Tip
As mentioned earlier, the HTML5 is . You’ll note that it’s
significantly simpler than earlier DOCTYPEs, and that was intentional. A lot has changed in
HTML5 in an attempt to make it even easier to develop a standards-based web page, and it
should really pay off in the end. One nice thing about this new DOCTYPE is that all current
browsers (IE, FF, Opera, Safari) will look at it and switch the content into standards mode, even
if they don’t implement HTML5. This means that you could start writing your web pages using
HTML5 today, without having to worry about future compatibility.
Related to XHTML
Header Elements
Problem
You want to add metadata to a document. You also want to link the document to style sheets
and JavaScript files. You also want to improve performance by embedding CSS rules and
JavaScript inside the page.
Solution
You can use to link style sheets to a
document. You can use href=”URI” to specify the URI of the style sheet. You can use
media=”all” to apply a style sheet to all devices. You can use media=”print” to apply a style
sheet only when printing. This allows you to hide navigational bars, remove backgrounds,
reset inverse color schemes (like white text on a black background) to normal black text on a
white background, and so forth. You can use media=”handheld” to apply a style sheet to
handheld devices only. You may find this impractical because styles that work on one
handheld device may be ignored or not work at all on another. Few browsers have
implemented the following media types: “tty” , “tv” , “projection” , “braille” , and
“aural” .
You can use to provide a user with alternate style
sheets. Most browsers put alternate style sheets in a drop-down list and allow users to select
and apply one alternate style sheet at a time to a document. Since most web sites do not
provide alternate style sheets and since there is no visual indication that they are available,
few users look for them or use them. Thus, sites that supply alternate style sheets often put
buttons or menus in the document and link them to JavaScript that switches between
alternate style sheets.
You can embed styles in the element. These should be styles specific only to the
current document. Styles that are used for more than one document should be contained in
external style sheets. You may find that putting styles directly in a document greatly speeds
the rendering of the document because a browser has fewer files to download. You may also
find that this increases the amount of work it takes to maintain a web site.
Other elements are common in , such as , , and . I have
included these elements in the example, but their usage is beyond the scope of this book.
Pattern
HTML
<head>
<base></base>
<link></link>
<link></link>
<style>
STYLES Location , , <title> , <meta> , <base> and <script> belong in <head> . Related to HTML Structure, Conditional Style Sheet Conditional Style Sheet Problem You want one set of styles to be applied to Internet Explorer and another set to be applied to other browsers. Solution You can use Microsoft Internet Explorer’s conditional comments to load a style sheet created exclusively for Internet Explorer. You can place a conditional comment in <head> after all links to other style sheets. Inside the conditional comment, you can place a link to a style sheet. I call this the conditional style sheet. Since the conditional style sheet comes last, it overrides previously loaded styles. You can create a separate conditional style sheet for Internet Explorer 6, and if necessary you can create one for Internet Explorer 7. You can include styles in this style sheet to compensate for different behaviors and bugs. The following pattern loads two conditional style sheets. The first is for Internet Explorer versions 6 and earlier. The second is for Internet Explorer 7 and higher. Internet Explorer 7 fixes most of the bugs in Internet Explorer 6, but there are still a number of CSS features that it does not implement, such as the content property. Pattern HTML <!--[if lte IE 6]> <link rel="stylesheet" href="ie6.css" media="all" type="text/css" /> <![endif]--> <!--[if gt IE 6]> <link rel="stylesheet" href="ie.css" media="all" type="text/css" /> <![endif]--> Limitations Conditional style sheets apply only to Internet Explorer. This is unfortunate because they are a good way to work around browser-specific problems. Fortunately, there are few problems in other browsers. I do not recommend CSS hacks because they rely on parsing bugs in a browser’s CSS engine. When these bugs get fixed, the hack no longer works. For this reason, I do not use or discuss CSS hacks in this book. In other words, all the design patterns in this book work without hacks. Also in Internet Explorer 10, this is considered a legacy feature and will work only in legacy mode. <!--[if IE]> This content is ignored in IE10 and other browsers. <![endif]--> Variations To target different versions of Internet Explorer, you can change the operator and version in the conditional comment. For example, you can use <!--[if lt IE 5]> or <!--[if IE 7]> . The following operators are available: lte (less than or equals), lt (less than), gt (greater than), or gte (greater than or equals). You can omit the operator for an equals comparison, such as <!--[if IE 7]> . If another browser ever implements conditional comments, you can replace IE with the constant that identifies that browser. Related to Header Elements Structural Block Elements Problem You want to structure your document so web browsers can render an enhanced view of the document; search engines can determine important keywords; document processors can use technologies like XSLT to extract content and transform the structure; and JavaScript can navigate the structure to modify content and make a document interactive. Solution You can mark up a document with block elements to identify its structure. There is meaning in structure, and HTML markup is most meaningful when its structure reflects the hierarchy and relationships of a document’s topics. Because a parent element contains child elements, they are related structurally. This implies their content is related. For example, a child’s content is typically a subtopic of its parent’s topic, and siblings typically have related subtopics. Implicit in the hierarchical nature of HTML is the assumption that document organization is hierarchical. Structural blocks may contain block elements only. They have structural meaning, but they have little semantic meaning. In other words, they do not tell you what something is; they tell you how it is organized. There are four major structural block elements ( <ol> , <ul> , <dl> , and <table> ) with nine supporting structural elements ( <li> , <dt> , <dd> , <caption> , <thead> , <tfoot> , <tbody> , <colgroup> , and <col> ). Details <ol> creates an ordered list of one or more list items ( <li> ). Items belong to the same set and are in order. Order implies sequence or ranking. <ul> creates an unordered list of one or more list items ( <li> ). Items belong to the same set without sequence or ranking. <dl> creates a definition list of one or more terms ( <dt> ) and definitions ( <dd> ). Structurally, a definition list implies all its terms are synonyms and all its definitions are alternate definitions of its terms. The HTML specification also shows that a definition list can have a broader application, such as listing speakers and their dialog. In generic terms, a definition list is an associative entity that associates keys with values. <table> creates a tabular data structure in rows ( <tr> ) and cells ( <th> and <td> ). It may optionally contain groups of rows: one table header ( <thead> ), one table footer ( <tfoot> ), and one or more table body groups ( <tbody> ). It may optionally contain one or more column groups ( <colgroup> ) containing one or more columns ( <col> ). Column groups and columns are the only structural blocks that are relational instead of hierarchical. In other words, each <col> element forms a relationship with cells in a column without actually being their parent. A table may optionally contain a <caption> . <div> is a multi-purpose block element. It can be structural or terminal. I mention it here because it normally creates a document division. Document divisions are essential for organizing a document into sections, and sections are the essential building blocks of documents. That is why I list <div> as the parent of all structural elements in the HTML Structure design pattern. <article> represents a self-contained composition in a page that is, in principle, independently distributable or reusable, e.g., via syndication. This could be a forum post, a magazine or newspaper article, a blog entry, etc. When article elements are nested, the inner article elements represent articles that are in principle related to the contents of the outer article. For instance, a blog entry on a site that accepts user-submitted comments could represent the comments as article elements nested within the article element for the blog entry. <section> represents a generic section of a document and acts as a thematic grouping of content, typically with a heading. Examples of sections would be chapters, the various tabbed pages in a tabbed dialog box, or the numbered sections of a thesis. A web site’s home page could be split into sections for an introduction, news items, and contact information. Developers may use <article> instead of the section element when it would make sense to syndicate the contents of the element. <nav> defines a section of a page that links to other pages or to parts within the page—basically a section with navigation links. Related to HTML Structure, Terminal Block Elements, Multi-purpose Block Elements Terminal Block Elements Problem You want to transition from document structure to content. Solution You can use one of the following terminal blocks to terminate document structure so you can insert content: <h1> , <p> , <blockquote> , <dt> , <address> , and <caption> . These elements are the primary containers of content. The multi-purpose block elements discussed in the next design pattern may also contain content. Paragraphs contain most of a document’s content followed by headings, blockquotes, list items, and table cells. Terminal blocks are terminal nodes in the block structure of a document. They cannot contain blocks. They contain text and inline elements. Structurally, they are siblings to other terminal and structural blocks, which implies they all have subtopics related to their parent block’s topic. Terminal blocks mainly have semantic meaning. HTML supplies six elements you can use to identify the purpose of content: heading, paragraph, blockquote, definition term, address, and caption. Details <h1>, <h2>, <h3>, <h4>, <h5> , and <h6> create headings from most important to least. Headings are relational. They imply the following sibling elements (typically paragraphs) have a subtopic that supports the topic of the heading. They also imply a relationship to each other. For example, <h2> implies that it is a subtopic of the previous <h1> element. Headings placed at lower levels of document structure typically have higher heading numbers. You can reinforce the structure of a document by making a heading the first element of each document division. <p> creates a paragraph. Semantically, a paragraph contains one or more sentences. The first sentence defines the topic of the paragraph, and subsequent sentences support that topic. The topic of a paragraph is typically a subtopic of the previous heading and relates to sibling elements. <blockquote> creates a blockquote. Semantically, a blockquote contains a quote from an external source that relates to the topic of its siblings. <dt> creates a definition term. Semantically, a definition term is a term that is being defined directly in the document by one or more definitions. The Structural Block Elements design pattern includes <dt> because it is a part of the <dl> structure. When you use <dl> as an associative entity, <dt> changes its semantic meaning to being a key that is associated with one or more values. Like a term, a key can be looked up to find its associated items. <address> creates a contact record for the document itself. It is not for identifying other types of addresses, such as your favorite restaurants. The HTML specification allows an address to contain any type of content such as a street address, e-mail address, phone number, etc. <caption> creates a table caption. Semantically, it labels a table. <caption> is referred to in the Structural Block Elements design pattern because it is a part of the <table> structure. Related to HTML Structure, Structural Block Elements, Multi-purpose Block Elements Multi-purpose Block Elements Problem You want the flexibility of extending the document structure by nesting structures within structures or terminating the current structure. Solution HTML provides seven elements— <div> , <li> , <dd> , <td> , <th> , <form> , and <noscript> — that can extend the structure or terminate it. For this reason, I call them multi-purpose block elements, as they are the most versatile elements. You can use them to identify document divisions, list items, dictionary definitions, table data cells, table header cells, forms, and alternate content to display when scripting is unavailable. When a multi-purpose block is used structurally, it has structural meaning. When it is used terminally, it has semantic meaning. For example, when a list item is terminal, it identifies its content as an item in a list. When a list item contains a structural block, such as a table or another list, it functions structurally as a node in a larger nested structure. Multi-purpose blocks may contain blocks or content, but not both. Content is defined as text intermingled with inline elements (images, objects, controls, and semantic markup). Block elements should not be siblings with inline elements and text. This is called mixed content. Content should always be contained within a block—not placed in between blocks. Because of limitations in HTML’s Document Type Definition language, HTML validators do not always invalidate a document containing mixed content, but this does not mean you should allow it. When a browser encounters mixed content, it wraps the content in an anonymous block. This is because a browser cannot render blocks and content at the same time, as blocks flow down the page and content flows across. CSS selectors cannot select anonymous blocks, which prevents you from being able to style anonymous blocks. Details <div> is a division. It is normally structural, but it can contain content. As shown in the example, the block structure created by divisions is invisible unless you style each division’s margins, border, and/or padding. <li> is a list item. Typically, it is a terminal block containing content, but it may contain structural blocks such as tables and lists, or terminal blocks such as headings and paragraphs. <dd> is a definition in a definition list. Typically, it is a terminal block containing content, but it may contain structural or terminal blocks. <td> and <th> are table cells. <td> is a data cell and <th> is a header cell. Typically, cells are terminal blocks containing content, but they may contain structural or terminal blocks. <form> is a data-entry form. It may contain structural blocks that organize form controls (as shown in this example), or it may directly contain inline form controls (as shown in the HTML Structure example). It may also contain terminal blocks such as headings and paragraphs. <noscript> is displayed when a browser does not support scripting. It may contain simple inline content, or it may contain a fully structured document. Related to HTML Structure, Structural Block Elements, Terminal Block Elements See also www.cssdesignpatterns.com/multi-purpose-block-elements Inline Elements Problem You want to add explicit meaning to text, and you want to style text to reflect this meaning. Solution HTML provides inline elements to identify the meaning of text, to control the flow of text, and to insert external content into the document, such as images and controls. Inline elements are content. Intermingling inline elements and text is desirable. Some call this mixed content, but I prefer to define mixed content narrowly as blocks, text, and inlines being mixed together, which is undesirable. I define content as text mixed with inline elements, which is desirable. This clearly separates structure from content and emphasizes that inline elements and text should always be contained within blocks—not in between blocks. I organize inline elements into four types: semantic, flow, replaced, and controls. Semantic elements identify the meaning of their content. Flow elements control the flow, such as inserting a line break. Replaced elements are replaced with an object, such as an image. Controls are objects used for data entry, such as a text box. HTML assigns each semantic inline element to a default style to emphasize that its text has a particular meaning. For example, <code> is rendered in a monospace font. You can use CSS to override these default styles. Details Three semantic inline elements specify the relative importance of their content; they are listed in order of increasing importance as follows: <span> , <em> , and <strong> . <span> is generic and has neutral importance. Search engines use <em> and <strong> to rank content. I have organized the remaining semantic inline elements by how much content they typically contain, such as a phrase, a word, or a character. Phrase inlines include <a> , <cite> , <code> , <kbd> , <samp> , and <var> . Word inlines include <abbr> , and <dfn> . Character inlines include <sub> and <sup> . Flow-control elements control the flow of content, such as <br /> , which inserts a line break, and <bdo> , which changes the direction of the flow. Replaced elements are replaced by external content, such as <img> , which is replaced by an image or <object> , which can be replaced by a video, a Flash movie, a sound file, etc. Controls are inline elements used for data entry in forms, such as <input> , <textarea> , <select> , and <button> . Default Styles HTML assigns default styles to each semantic inline element. <span> has no default style and meaning, so you can use it for any purpose. <strong> is bold by default. The following are italicized by default: <em> , <dfn> , <cite> , and <var> . The following are monospace by default: <code> , <kbd> , and <samp> . The following are underlined by default: <a> and <abbr> . Internet Explorer 6 does not support <abbr> . Related to HTML Structure; all design patterns in Chapters 10 through 12 and 14 See also www.cssdesignpatterns.com/inline-elements Class and ID Attributes Problem You want to identify some elements as being in the same class as other elements. You want to apply additional semantic and relational meaning to a class of elements. You want to style a class of elements in the same way. You want to identify some elements uniquely in a document so you can style them uniquely and directly access them through JavaScript. Solution HTML supplies the class and id attributes for these purposes. You can assign a class and an id to any element. An ID and class name cannot include a space. It must start with a letter and may contain letters, numbers, the underscore ( _ ), and the dash ( - ). Since CSS selectors are case-sensitive when using XHTML, it is a common practice to use lowercase class and ID names. Class ID class assigns a user-defined semantic meaning to an element. class is the primary mechanism for extending the semantic meaning of HTML elements. Elements with the same class are related and can be manipulated as a group. You can use CSS selectors to apply a style to a class of elements. You can use a document processor, such as XSLT, to manipulate a class of elements. You can assign multiple classes to an element by putting multiple class names in an element’s class attribute. A space separates each class name. Classes should have semantic names, such as copyright, date, price, back-to-top, example, figure, listing, illustration, note, result, tip, warning, etc. An ID should be unique within a document. If it is not, a CSS ID selector will match all elements with the same ID—just like the class attribute. You can use a unique ID as a CSS selector to style one element. You can use it as an anchor that can be targeted by other links. You can use it to access and manipulate a specific element from JavaScript or a document processor. IDs should have semantic names, such as skip-to-main-content, page, preheader, header, title, search, postheader, body, nav, site-map, links, main, section1, section2, news, about- us, services, products, etc. Patterns HTML CSS <ELEMENT id="id" class="class1 class2 etc" ></ELEMENT> #id { STYLES } *.class { SYTLES } Tip Since <div> and <span> elements have no semantic meaning, you can assign classes to them without conflicting with any predefined meaning. You can assign classes to <div> to create custom document structures with custom semantic meaning. You can assign classes to <span> to customize the meaning of text. There are currently no standard class names with precise predefined meanings, although the microformats movement is making progress toward that goal by mapping HTML structure and class names to common standards, such as hCard and hCalendar. Related to Type, Class, and ID Selectors, Subclass Selector (Chapter 3) HTML Whitespace Problem You want to use whitespace in markup to make the code more readable without the whitespace affecting the rendering of the document. Solution A browser collapses repeated whitespace into a single space. This allows you to insert extra spaces, tabs, newlines, and returns into the markup to make it more readable without it showing up in the rendered document. A browser interprets only the following characters as whitespace: space ( &amp;#x0020; ), tab ( &amp;#x0009; ), newline ( &amp;#x000A; ), and return ( &amp;#x000D; ). Empty elements and elements containing only whitespace do not interrupt a contiguous sequence of whitespace. Notice in the first paragraph of the example how a browser renders only one space between the words “start,” “middle,” and “end”—even though there are many characters between these words including spaces, tabs, newlines, returns, whitespace entities, an empty span, and a span containing whitespace. The first whitespace character in a series of contiguous whitespace characters determines the position and style of the collapsed space. In other words, a browser renders collapsed space using the font-family , font-size , font-weight , line-height , and letter-spacing assigned to the first whitespace character of the series. Larger fonts, wider letter-spacing , and taller line-height create wider and taller whitespace. Thus, the location of whitespace in an HTML document determines how wide and tall it is. The second and third paragraphs of the example show how the location of whitespace determines whether it collapses inside an element or outside. If it collapses inside, it is styled by the element’s rules. Since whitespace collapses to the left, you can collapse whitespace in front of an element by simply putting whitespace before it. If you want whitespace to collapse inside an element, you need to remove all whitespace before the element and put at least one whitespace inside it. If you want whitespace to be inside an element and to be placed after its content, simply follow the content with whitespace. If you want whitespace to collapse outside the closing tag of an element, you need to remove all whitespace following the element’s content and insert whitespace after the element. You can put extra whitespace inside an element’s start and end tags without putting undesired whitespace in the content. You can insert extra whitespace between the start tag’s name and its attributes; surrounding an attribute’s name, equal sign, and value; and before the start tag’s greater-than sign. You can insert extra whitespace between the end tag’s name and its greater-than sign. The fourth paragraph of the example is an extreme example that has much whitespace inside the tags but none inside the content. Space Entities HTML provides five space entities that have different widths. These are not whitespace! The nonbreaking space, &amp;nbsp; , is the width of a normal space and works in all major browsers; the widths of the other spaces ( &amp;zwnj; , &amp;thinsp; , &amp;ensp; , and &amp;emsp; ) vary in different browsers. Preserved The <pre> element preserves all the whitespace that is inside it. Related to Spacing, Nowrap, Preserved, Padded Content, Inline Spacer, Linebreak (Chapter 11)</li></ol></dd></li></h1></li></ol></dd></li></style></head>
Page Layouts with tables and div’s:
- applicability for each of them
https://www.smashingmagazine.com/2009/04/from-table-hell-to-div-hell/
Accessibility in HTML5
http: //www.clarissapeterson.com/2012/11/html5-accessibility/
https: //www.html5accessibility.com/
Frames and iFrames:
- applicability
https: //krasimirtsonev.com/blog/article/iframe-or-not-that-is-the-question
https: //tweakyourbiz.com/technology/3-reasons-avoid-iframes-business-website
Web-components:
- advantages and disatvantages
http: //kaytcat.github.io/web-components/
https: //vaadin.com/blog/web-components-in-production-use-are-we-there-yet-
HTML Browser compatibility
https://www.w3schools.com/html/html5_browsers.asp
Canvas:
- Draw a Line
- Draw a Circle
- Draw a Text
- Stroke Text
https: //www.sitepoint.com/html5-canvas-tutorial-introduction/
https: //billmill.org/static/canvastutorial/index.html