HTML and CSS Reference
In-Depth Information
Figure 1-6. Sample CSS styles
Tip: Dont be concerned if you dont understand everything immediately—youll find lots of help on the
Web. In particular, see the official source for HTML 5 at http://dev.w3.org/html5/
spec/Overview.html .
There are many things you can do with CSS. You can use it to specify formatting for types of elements, as
shown above; you can specify that elements are part of a class; and you can identify individual elements
using the id attribute. In Chapter 6 where we create a quiz, I use CSS to position specific elements in the
window and then JavaScript to move them around.
JavaScript programming
JavaScript is a programming language with built-in features for accessing parts of an HTML document,
including styles in the CSS element. It is termed a scripting language to distinguish it from compiled
languages, such as C++. Compiled languages are translated all at once, prior to use, while scripting
languages are interpreted line by line by browsers. This text assumes no prior programming experience or
knowledge of JavaScript, but it may help to consult other topics, such as Getting Started with
JavaScript , by Terry McNavage (friends of ED, 2010), or online sources such as
http://en.wikipedia.org/wiki/JavaScript . Each browser owns its version of JavaScript.
An HTML document holds JavaScript in a script element, located in the head element. To display the
time and date information as shown in Figure 1-2, I put the following within the head element of the HTML
document:
<script>
document.write(Date());
</script>
JavaScript, like other programming languages, is made up of statements of various types. In later
chapters, Ill show you assignment statements, compound statements such as if and switch and for
 
Search WWH ::




Custom Search