Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

HTML, CSS, and JavaScript Files

The HTML, CSS, and JavaScript files provide the implementation of the widget. In these files, you can use any technique or trick that you would use when designing a webpage. This includes, but is not limited to, HTML, CSS, and JavaScript. Use JavaScript to introduce interactivity into your widget.

While you can place all of your HTML, CSS, and JavaScript code into one file, you may find it more manageable to split these into separate files, as shown in Table 2-1. Splitting your markup, design, and logic into separate files may also make localization easier, as discussed later on in Localizing Widgets. In general, file extensions are used to reflect the purpose of the file:

Table 2-1  File extension mappings for web technologies

Technology

Purpose

File extension

Example

HTML

Structure

.html

HelloWorld.html

CSS

Design

.css

HelloWorld.css

JavaScript

Logic

.js

HelloWorld.js

These file extensions are not enforced by Dashboard, but it is recommended that you adhere to these standards.

To load your CSS and JavaScript, you'll need to import them inside of your HTML file. For importing a style sheet, the markup looks like this:

<style type="text/css">
    @import "HelloWorld.css";
</style>

To load a JavaScript file, use the <script> tag:

<script type='text/javascript' src='HelloWorld.js'></script>

Note that if your widget does not use CSS or JavaScript, there is no need to use these includes or to include blank CSS or JavaScript files. Conversely, you can use multiple @import statements and <script> tags to include more than one CSS or JavaScript file.



< Previous PageNext Page > Hide TOC


Last updated: 2006-01-10




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice