04.07.2013 Views

Start Here! Learn JavaScript - Cdn.oreilly.com

Start Here! Learn JavaScript - Cdn.oreilly.com

Start Here! Learn JavaScript - Cdn.oreilly.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

webpage example already discussed, the Microsoft site is likely running a server-based language such<br />

as Microsoft Visual Basic or C# to create the webpages. <strong>JavaScript</strong> also runs in desktop widgets (notably<br />

in Windows 8), in PDF documents, and in other similar places. This section explores how <strong>JavaScript</strong><br />

interacts with other client languages to provide a rich application experience.<br />

Note <strong>JavaScript</strong> is also used as a server-side language with frameworks such as Node.js,<br />

but <strong>JavaScript</strong>’s primary use remains as a client-side language.<br />

htML, CSS, and <strong>JavaScript</strong><br />

The languages of front-end web development consist of HTML, CSS (Cascading Style Sheets), and<br />

<strong>JavaScript</strong>. HTML provides the descriptive elements that surround content to define the layout of the<br />

page. CSS provides the styling to make the marked-up content visually appealing. <strong>JavaScript</strong> provides<br />

the functional and behavioral aspects to both the content and the styling. These front-end languages<br />

are typically <strong>com</strong>bined with back-end, server-side languages such as PHP, Visual Basic/C#, Java, or<br />

Python to create a full web application.<br />

htML<br />

HTML is the language of the web. It’s the language developers use to create webpages. You can<br />

create working webpages and web applications with nothing more than just HTML; however, to<br />

today’s sophisticated users, such pages would be boring and look horrible—but they would be<br />

webpages nonetheless. HTML is a standard or specification (two terms that are used relatively interchangeably,<br />

in this case) defined by the World Wide Web Consortium (W3C). There are several iterations<br />

of the HTML specification. The most current is version 5, known simply as HTML5.<br />

HTML consists of elements enclosed in angle brackets (< and >). You already saw examples of<br />

HTML elements in the first tutorial in the chapter. HTML elements, also called tags, describe the content<br />

they enclose and how that content should be rendered by the browser. For example, an HTML<br />

tag for an image element is . When the browser’s rendering engine encounters that tag, it<br />

knows the contents of that tag should be a reference to an image file. Similarly, the tag denotes<br />

a paragraph. Most tags, like , also have a closing or matching tag used to denote the end of that<br />

element. In the case of , the closing tag is . Other tags use a similar syntax, with a forwardslash<br />

(/) used to denote the end of the tag.<br />

Tags can contain other content, called attributes, within their angle brackets. Attributes provide<br />

additional information about the content. Some attributes are generic and can be used with all tags,<br />

while others are specific to particular elements, such as the tag. For example, the tag<br />

uses the src attribute to specify the location of the image file that the browser will load and render.<br />

<strong>Here</strong>’s an tag that references an image called “SteveSuehring.jpg”:<br />

<br />

4 <strong>Start</strong> here! <strong>Learn</strong> <strong>JavaScript</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!