HTML and CSS Reference
In-Depth Information
tribute values from CSS, you type the value and then prefix IDs with a hash sign (
#
) and
classes with a period (
.
), like this:
#about-text { background: blue; }
.homepage { color: white; }
To reference these attribute values from JavaScript, you would typically use the
command
document.getElementById("about-text")
from within your
JavaScript, where
about-text
is replaced with whatever the actual ID is of the
element you want to gain access to. A similar command is available for retrieving
all elements with a particular class value:
docu-
ment.getElementsByClassName("homepage")
(where
homepage
is re-
placed with the class value you are referencing).
Editability
The
contenteditable
attribute is used in the new Editing APIs, well new as in
HTML standards new. The Editing APIs, which allow in-page edits of page content,
have had the attribute
contenteditable
since Internet Explorer introduced it in
2000, but it took until now to get the attribute into the HTML specification. The idea is
to allow elements of HTML to be edited so that rich-text editors for web forms and the
like can be more easily created (for creating marked-up text for a blog entry using a web
Spell-checking
The
spellcheck
attribute, as the name implies, is for specifying whether an element
should be spell-checked. Web browsers often have a spell-checking feature that checks
for spelling and grammatical errors as the user types into, for instance, a web form's in-
put fields. Sometimes it's desirable to disable this spell-checking feature on certain ele-
ments on the page. For example, you may not want to check for spelling errors on an
e-mail address typed into a web form, so the browser could be informed to ignore an
e-mail address form input control using the
spellcheck
attribute. The values for the
spellcheck
attribute are
true
or
false
(or an empty string of text
""
, which maps
to the true state). Naturally this fits quite well with content that can be edited.
Hiding elements
The
hidden
attribute, is for hiding and showing HTML elements. This is equivalent to
using the CSS property and value
display:none
. While using CSS for hiding ele-
Search WWH ::
Custom Search