HTML and CSS Reference
In-Depth Information
An element that does not enclose content is an empty element and it is marked with a
one-sided tag using the syntax
< element />
where element is the name of the element. For example, you can mark a line break
using the br element, which has the following syntax:
<br />
Since empty elements don't contain content, they're often employed to send directives
to browsers regarding how a page should be rendered. A browser encountering the br
element would insert a line break, causing the text of the next element in the document
to be placed on a new line.
Specifying an Element Attribute
In addition to content, elements also support attributes that specify the use, the behavior,
and in some cases the appearance of an element. Attribute values don't appear in the
rendered Web page; rather, they provide information to the browser about the properties
of the element.
To add an attribute to an element, you insert the attribute within the element's open-
ing tag. For a two-sided tag, the syntax is:
<element attribute1=”value1” attribute2=”value2” ...>
Attributes are added to one-sided tags in the same way:
<element attribute1=”value1” attribute2=”value2” ... />
In these examples, attribute1 , attribute2 , etc. are the names of attributes associ-
ated with the element, and value1 , value2 , etc. are the values of those attributes. For
instance, the following code adds the id attribute to a paragraph marked with the p
Attributes can be listed in
any order, but they must
be separated from one
another by a blank space
and enclosed within
single or double
quotation marks.
<p id=”opening”>Welcome to the J-Prop Shop.</p>
A browser interpreting this code would recognize that the text Welcome to the J-Prop
Shop. should be treated as a paragraph and given the id value opening .
Adding an Attribute to an Element
• To add an element attribute, use the format
<element attribute1=”value1”
ƒƒƒƒƒƒƒƒƒattribute2=”value2” ...>content</element>
where attribute1 , attribute2 , etc. are the names of attributes associated with the
element, and value1 , value2 , etc. are the values of those attributes.
White Space and HTML
Since an HTML fi le is a text fi le, it's composed of text characters and white space. White
space includes the blank spaces, tabs, and line breaks found within the fi le. As far as
a browser is concerned, there is no difference between a blank space, a tab, or a line
break. Browsers also ignore consecutive occurrences of white space, collapsing extra
Search WWH ::

Custom Search