HTML and CSS Reference
In-Depth Information
Figure 2.2: A web page with a heading and paragraph
In this example, another CSS rule has been added to the style element in
the head of the document, and some additional markup has been added to the
elements in the document body. he class attribute added to the paragraph
element (class="intro-text") is one of three attributes that can be used to
associate an HTML element with a set of CSS rules. One of the places CSS
rules can appear is in a style element in the document head. In Example 2.2,
the second style rule says that any element having a class attribute with the
value "intro-text" should be rendered in a 12-point sans serif font. By default,
this is usually the Arial or Helvetica typeface, but the readers of the page can
set their browser's preferences to other fonts.
Inside the paragraph element are two other HTML elements. he irst looks
rather strange because it appears to be a start tag for an element, but it is not
paired with an end tag. hat's exactly what it is. he break element, <br/> ,
inserts a line break into the text, which is like pressing Shit-Enter in Micro-
sot Word. he break element is an example of a self-closing HTML element.
Because a line break, unlike a heading or paragraph, cannot contain any
content, there's not much point in having a corresponding end tag to create a
container. he image tag is another important self-closing HTML element.
In the second line of the paragraph element, the words “I promise” are
emphasized by being enclosed in the emphasis element, <em></em> . he default
behavior is to render the enclosed text in italics. Unlike the heading and para-
graph elements, the emphasis element is an inline element . It does not change
the low of text. Headings and paragraphs are block elements and have box
properties that inline elements do not have, such as height, width, margins,
and padding.
he HTML5 speciication is structured so that the HTML elements of any
web page can be described in a hierarchical tree diagram with the html ele-
ment as the root, the head and body elements as the main trunks, and the rest
 
Search WWH ::




Custom Search