HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 43. CH42 ELEMENTS OF HTML 327


Thescripttag can come within the head and provides an interactive element
to the webpage. Typically scripting is done in JavaScript. Scripts respond
to and process events, such as mouseover and keypress, as well as real-time
webpage updating using things like AJAX.


Warning: Script can either specify a source file (src=) or immediately pro-
vide the JavaScript code. If it does both, the src= takes precedence and the
inline code is ignored.


Themetatag comes within the head and provides metadata that is not
otherwise available through title, base, link, style, script, and any other
things that might have their own tags.


43.2 The body Element


Some tags are identified as semantic. The semantic tags normally have
counterparts that are non-semantic. Semantic tags assert some additional,
special, cohesive meaning: this content is not just a div, it is an article or a
header or a footer.


Thebodytag (not semantic) identifies the body element, which is the
webpage content. It also supports the event handlers (JavaScript) that
affect the webpage content.


43.2.1 div and Friends


Thedivtag (not semantic) provides generic grouping of things. It does not
imply the content within has a shared theme. When the content does have
a shared theme, other tags likearticle,section, andnavmay be more
appropriate.


Thearticletag (semantic) is likediv, but it identifies a composition that
is perhaps like a blog post or a comment. The body may have any number
of articles. Articles may have sub-articles within themselves.


Thesectiontag (semantic) is likediv, but it implies the content within
shares the same theme. It is more general thanarticle.


Thenavtag (semantic) is likediv, but it implies the content is generally
there to provide links to related content. A screen-reader for the blind, for
example, might skip over the nav section without reading it aloud, because

Free download pdf