Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: src/site/docs/tutorials/connect-dart-html/index.markdown

Issue 26542002: edit pass on T3,4,5, updated images (Closed) Base URL: https://github.com/dart-lang/dartlang.org.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 --- 1 ---
2 layout: default 2 layout: default
3 title: "Connect Dart & HTML" 3 title: "Connect Dart & HTML"
4 description: "Shows basic scaffolding of a Dart web app" 4 description: "Shows basic scaffolding of a Dart web app"
5 has-permalinks: true 5 has-permalinks: true
6 tutorial: 6 tutorial:
7 id: connect-dart-html 7 id: connect-dart-html
8 next: add-elements/ 8 next: add-elements/
9 next-title: "Add Elements to the DOM" 9 next-title: "Add Elements to the DOM"
10 prev: get-started/ 10 prev: get-started/
11 prev-title: "Get Started" 11 prev-title: "Get Started"
12 --- 12 ---
13 13
14 {% capture whats_the_point %} 14 {% capture whats_the_point %}
15 15
16 * The DOM models a browser page in a tree/node structure. 16 * The DOM models a browser page in a tree/node structure.
17 * An HTML file hosts your Dart code in a browser page. 17 * An HTML file hosts your Dart code in a browser page.
18 * Use query() with an ID to get an element from the DOM. 18 * Use query() with an ID to get an element from the DOM.
19 * Control run-time configurations in Dart Editor with named launches.
20 * Compile to JavaScript to run in any modern browser. 19 * Compile to JavaScript to run in any modern browser.
21 * CSS selectors are patterns used to select matching elements in the DOM. 20 * CSS selectors are patterns used to select matching elements in the DOM.
22 * Use CSS rules to style elements. 21 * Use CSS rules to style elements.
23 22
24 {% endcapture %} 23 {% endcapture %}
25 24
26 {% capture sample_links %} 25 {% capture sample_links %}
27 26
28 <p> 27 <p>
29 Get the source code for the samples featured in this target:</p> 28 Get the source code for the samples featured in this tutorial:</p>
30 29
31 <ul> 30 <ul>
32 <li> 31 <li>
33 <a href="https://github.com/dart-lang/dart-tutorials-samples/tree/master/web /target02/mini" 32 <a href="https://github.com/dart-lang/dart-tutorials-samples/tree/master/web /connect-dart-html/mini"
34 target="_blank">mini</a> 33 target="_blank">mini</a>
35 </li> 34 </li>
36 <li> 35 <li>
37 <a href="https://github.com/dart-lang/dart-tutorials-samples/tree/master/web /target02/mini_with_style" 36 <a href="https://github.com/dart-lang/dart-tutorials-samples/tree/master/web /connect-dart-html/mini_with_style"
38 target="_blank">mini_with_style</a> 37 target="_blank">mini_with_style</a>
39 </li> 38 </li>
40 </ul> 39 </ul>
41 40
42 {% endcapture %} 41 {% endcapture %}
43 42
44 {% capture content %} 43 {% capture content %}
45 44
46 <div class="tute-target-title"> 45 <div class="tute-target-title">
47 <h1>{{page.title}}</h1> 46 <h1>{{page.title}}</h1>
(...skipping 18 matching lines...) Expand all
66 Though simple, 65 Though simple,
67 this example shows you how to connect a Dart 66 this example shows you how to connect a Dart
68 app to an HTML page and 67 app to an HTML page and
69 one way that a Dart app can interact with items on the page. 68 one way that a Dart app can interact with items on the page.
70 These concepts 69 These concepts
71 provide the foundation 70 provide the foundation
72 for more interesting and useful web apps. 71 for more interesting and useful web apps.
73 72
74 * [About the DOM](#dom-intro) 73 * [About the DOM](#dom-intro)
75 * [Create a new Dart app](#create-dart-app) 74 * [Create a new Dart app](#create-dart-app)
75 * [Edit the HTML file](#create-html)
76 * [About the HTML source code](#about-html-code)
76 * [Edit Dart source code](#dart-editor-happiness) 77 * [Edit Dart source code](#dart-editor-happiness)
77 * [About the Dart source code](#about-dart-code) 78 * [About the Dart source code](#about-dart-code)
78 * [Edit the HTML file](#create-html) 79 * [Summary of HTML and Dart connections](#summary)
79 * [About the HTML source code](#about-html-code)
80 * [Run the mini web app](#run-mini) 80 * [Run the mini web app](#run-mini)
81 * [Create a JavaScript launch](#mini-with-js)
82 * [Give the app some style with CSS](#add-css) 81 * [Give the app some style with CSS](#add-css)
83 * [About CSS selectors](#about-css-selectors) 82 * [About CSS selectors](#about-css-selectors)
84 * [Other resources](#other-resources) 83 * [Other resources](#other-resources)
84 * [What next?](#what-next)
85 85
86 ##About the DOM {#dom-intro} 86 ##About the DOM {#dom-intro}
87 87
88 The Document Object Model (DOM) 88 The Document Object Model (DOM)
89 represents the structure of a web document as a tree of nodes. 89 represents the structure of a web document as a tree of nodes.
90 When an HTML file is loaded into a browser, 90 When an HTML file is loaded into a browser,
91 the browser interprets the HTML 91 the browser interprets the HTML
92 and displays the document in a window. 92 and displays the document in a window.
93 The following diagram shows a simple HTML file and 93 The following diagram shows a simple HTML file and
94 the resulting web browser page in Chrome. 94 the resulting web browser page in Chrome.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 alt="A Dart program can dynamically change the DOM"> 138 alt="A Dart program can dynamically change the DOM">
139 139
140 The diagram shows a small Dart program that makes 140 The diagram shows a small Dart program that makes
141 a modest change to the DOM by dynamically 141 a modest change to the DOM by dynamically
142 changing a paragraph's text. 142 changing a paragraph's text.
143 A program could add and delete nodes, 143 A program could add and delete nodes,
144 or even insert an entire sub-tree of nodes. 144 or even insert an entire sub-tree of nodes.
145 145
146 ## Create a new Dart app {#create-dart-app} 146 ## Create a new Dart app {#create-dart-app}
147 147
148 The application you write in this target will be a web application. 148 The application you write in this tutorial is a web application.
149 Web applications use code from the browser package to run inside of a browser, 149 Web applications use code from the `browser` package
150 to run inside of a browser,
150 so you need to start with the supporting files and packages 151 so you need to start with the supporting files and packages
151 even for the smallest web app. 152 even for the smallest web app.
152 153
153 In Dart Editor, create a new application called mini. 154 In Dart Editor, create a new web application
154 Select **Generate sample content** 155 like you did in the previous tutorial
Kathy Walrath 2013/10/08 21:25:22 tutorial -> tutorial,
mem 2013/10/09 17:07:31 Done.
155 and **Web application**. 156 [Get Started](/docs/tutorials/get-started/).
157 Name the app `mini`.
156 158
157 <img src="images/new-app-mini.png" 159 <img src="images/new-app-mini.png"
158 alt="New Application dialog window"> 160 alt="New Application dialog window">
159 161
160 Dart Editor creates a directory called mini and, within it, 162 ##Edit the HTML file {#create-html}
161 the files and directories needed for a web application.
162 163
163 <img src="images/new-app-files.png" 164 When Dart Editor created the application,
164 alt="After new application created"> 165 it created boilerplate HTML code.
166 Double click `mini.html` to open it
167 and replace the code with the following,
Kathy Walrath 2013/10/08 21:25:22 open it and replace -> open it. Then replace
mem 2013/10/09 17:07:31 Done.
168 simplied HTML.
165 169
166 * The top-level directory is named after the application. 170 {% prettify html %}
171 <!DOCTYPE html>
167 172
168 * The pubspec.yaml file is used by applications 173 <html>
169 that rely on external packages of Dart code. 174 <head>
170 [Target 5: Install Shared Packages](/docs/tutorials/shared-pkgs/) 175 <title>A Minimalist App</title>
171 provides more information. 176 </head>
172 Web applications use a package called `browser`. 177
173 This dependency is declared in the pubspec.yaml file. 178 <body>
179 <p id="RipVanWinkle"></p>
180 <script type="application/dart" src="mini.dart"></script>
181 <script src="packages/browser/dart.js"></script>
182 </body>
183 </html>
184 {% endprettify %}
174 185
175 * The web directory contains the Dart, HTML, and CSS code for the web app. 186 Finish your edits and save the file with **File > Save**.
176 187
177 * The main source file, mini.dart in this sample, 188 ##About the HTML source code {#about-html-code}
178 contains boilerplate code for the clickme app 189
179 you saw in the previous target. 190 This HTML code is similar to the simple HTML code in the
180 You will edit the code in this file and 191 various diagrams earlier in this tutorial.
181 in mini.html to create a bare-bones app. 192 Again, you can see the use of the \<head>, \<title>, \<body>,
193 and \<p> tags.
194 And there, in the paragraph tag,
195 is an identifier "RipVanWinkle".
196 The Dart code you create in the next step uses this ID
197 to get the paragraph element.
198
199 <img src="images/html-id.png"
200 alt="Using an ID in HTML">
201
202 Notice the use of the `script` tag.
203 A script's content is defined by a client-side script.
Kathy Walrath 2013/10/08 21:25:22 This sentence doesn't make sense to me. Should the
mem 2013/10/09 17:07:31 Done.
204 The HTML code above has two scripts.
205
206 <img src="images/script-tags.png"
207 alt="Including Dart apps in HTML">
208
209 The first includes your mini app.
210 It uses two attributes: `type` indicates the type of the script.
Kathy Walrath 2013/10/08 21:25:22 This confused me because the thing to the right of
mem 2013/10/09 17:07:31 Done.
211 `application/dart` is a new type created by the Dart team,
212 which is currently supported by Dartium.
213 The `src` attribute provides the URL to the source file of the script.
214 In this case, it is the Dart source file `mini.dart`,
215 which you provide in the next step.
216 The Dart file should be in the same directory as its host HTML file.
217
218 The second `script` tag is
219 a bootstrap script that takes care of turning on the Dart VM,
220 as well as compatibility with non-Dart browsers.
182 221
183 ##Edit Dart source code {#dart-editor-happiness} 222 ##Edit Dart source code {#dart-editor-happiness}
184 223
185 Use Dart Editor 224 Open `mini.dart` and modify the source code
186 to modify the source code
187 to look like this: 225 to look like this:
188 226
189 {% prettify dart %} 227 {% prettify dart %}
190 import 'dart:html'; 228 import 'dart:html';
191 void main() { 229 void main() {
192 query('#RipVanWinkle').text = 'Wake up, sleepy head!'; 230 query('#RipVanWinkle').text = 'Wake up, sleepy head!';
193 } 231 }
194 {% endprettify %} 232 {% endprettify %}
195 233
196 <i class="icon-info-sign"> </i>
197 <a href="errors-warnings.html">What is Dart Editor trying to tell me?</a>
198
199 ##About the Dart source code {#about-dart-code} 234 ##About the Dart source code {#about-dart-code}
200 235
201 Let's step through the code. 236 Let's step through the code.
202 237
203 ###Importing libraries 238 ###Importing libraries
204 239
205 The import directive imports the specified library, 240 The import directive imports the specified library,
206 making all of the classes and functions 241 making all of the classes and functions
207 in that library 242 in that library
208 available to your program. 243 available to your program.
209 244
210 <img src="images/0-mini-code-walk-through.png" 245 <img src="images/0-mini-code-walk-through.png"
211 alt="Import Dart HTML library"> 246 alt="Import Dart HTML library">
212 247
213 This program imports Dart's HTML library, 248 This program imports Dart's HTML library,
214 which contains the classes and functions for programming the DOM. 249 which contains the classes and functions for programming the DOM.
Kathy Walrath 2013/10/08 21:25:22 the classes and functions -> classes and functions
mem 2013/10/09 17:07:31 Done.
215 Generally speaking, all Dart web apps need the Dart HTML library. 250 Generally speaking, all Dart web apps need the Dart HTML library.
Kathy Walrath 2013/10/08 21:25:22 Is this still true? Can't some polymer apps get aw
mem 2013/10/09 17:07:31 Done.
216 Key classes include: 251 Key classes include:
217 252
218 | Dart class | Description | 253 | Dart class | Description |
219 |---|---| 254 |---|---|
220 | <a href="https://api.dartlang.org/dart_html/Node.html" target="_blank">Node</a > | Implements a Dart Node. | 255 | <a href="https://api.dartlang.org/dart_html/Node.html" target="_blank">Node</a > | Implements a Dart Node. |
221 | <a href="https://api.dartlang.org/dart_html/Element.html" target="_blank">Elem ent</a> | A subclass of Node, implements a web page element. | 256 | <a href="https://api.dartlang.org/dart_html/Element.html" target="_blank">Elem ent</a> | A subclass of Node, implements a web page element. |
222 | <a href="https://api.dartlang.org/dart_html/Document.html" target="_blank">Doc ument</a> | Another subclass of Node. Implements the document object. | 257 | <a href="https://api.dartlang.org/dart_html/Document.html" target="_blank">Doc ument</a> | Another subclass of Node. Implements the document object. |
223 {: .table} 258 {: .table}
224 259
225 The Dart core library contains another useful class, 260 The Dart core library contains another useful class,
226 <a href="https://api.dartlang.org/dart_core/List.html" target="_blank">List</a>, 261 <a href="https://api.dartlang.org/dart_core/List.html" target="_blank">List</a>,
227 a parameterized class that can specify the type of its members. 262 a parameterized class that can specify the type of its members.
228 The Element class keeps its list of child Elements 263 An instance of Element keeps its list of child Elements
229 in a List\<Element>, a list that can contain only Element objects. 264 in a List\<Element>, a list that can contain only Element objects.
Kathy Walrath 2013/10/08 21:25:22 "can contain" isn't really true, given Dart's opti
mem 2013/10/09 17:07:31 Done.
230 265
231 ###Using the query() function 266 ###Using the query() function
232 267
233 This app's main() function contains a single 268 This app's main() function contains a single
234 line of code that is a little like a run-on sentence 269 line of code that is a little like a run-on sentence
235 with multiple things happening one after another. 270 with multiple things happening one after another.
236 Let's deconstruct it. 271 Let's deconstruct it.
237 272
238 query() is a top-level function provided by the Dart HTML library 273 query() is a top-level function provided by the Dart HTML library
239 that gets an Element object from the DOM. 274 that gets an Element object from the DOM.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 you can simply use the Element `text` property, 315 you can simply use the Element `text` property,
281 which has a getter 316 which has a getter
282 that walks the subtree of nodes for you and extracts their text. 317 that walks the subtree of nodes for you and extracts their text.
283 318
284 <img src="images/4-mini-code-walk-through.png" 319 <img src="images/4-mini-code-walk-through.png"
285 alt="Text node child of the paragraph"> 320 alt="Text node child of the paragraph">
286 321
287 However, if the text node has styles (and thus a subtree), 322 However, if the text node has styles (and thus a subtree),
288 getting text and then setting it immediately is likely 323 getting text and then setting it immediately is likely
289 to change the DOM, as a result of losing subtree information. 324 to change the DOM, as a result of losing subtree information.
290
291 Often, as with our RipVanWinkle example, 325 Often, as with our RipVanWinkle example,
292 this simplification has no adverse effects. 326 this simplification has no adverse effects.
293 Do know, however, that with more complex situations
294 getting text and then setting it immediately
295 will likely change the text.
296 327
297 The assignment operator (=) sets the text 328 The assignment operator (=) sets the text
298 of the Element returned by the query() function 329 of the Element returned by the query() function
299 to the string "Wake up, sleepy head!". 330 to the string "Wake up, sleepy head!".
300 331
301 <img src="images/5-mini-code-walk-through.png" 332 <img src="images/5-mini-code-walk-through.png"
302 alt="Set the text node, thereby changing the text on the page"> 333 alt="Set the text node, thereby changing the text on the page">
303 334
304 This causes the browser to immediately re-render 335 This causes the browser to immediately re-render
305 the browser page containing this app 336 the browser page containing this app, thus
306 dynamically displaying the text on the browser page. 337 dynamically displaying the text on the browser page.
307 338
308 ##Edit the HTML file {#create-html} 339 ##Summary of HTML and Dart connections {#summary}
309 340
310 When Dart Editor created the application, 341 This diagram summarizes the connections
311 it created boilerplate HTML code that worked with the clickme app.
312 Now that you've modified the Dart code,
313 you will need to change the HTML code
314 so that it contains the expected RipVanWinkle paragraph.
315
316 In Dart Editor, double click `mini.html`.
317 The code appears in the editor pane.
318 Replace the default contents with the following,
319 simplified HTML.
320
321 {% prettify html %}
322 <!DOCTYPE html>
323
324 <html>
325 <head>
326 <title>A Minimalist App</title>
327 </head>
328
329 <body>
330 <p id="RipVanWinkle"></p>
331 <script type="application/dart" src="mini.dart"></script>
332 <script src="packages/browser/dart.js"></script>
333 </body>
334 </html>
335 {% endprettify %}
336
337 Finish your edits and save the file with **File > Save**.
338
339 ##About the HTML source code {#about-html-code}
340
341 This HTML code is similar to the simple HTML code in the
342 various diagrams earlier in this target.
343 Again, you can see the use of the \<head>, \<title>, \<body>,
344 and \<p> tags.
345 And there, in the paragraph tag,
346 is the identifier "RipVanWinkle"
347 that the Dart code you created in the previous step uses
348 as an argument to query() to get the paragraph element.
349
350 New here is the use of the `script` tag.
351 A script's content is defined by a client-side script.
352 The HTML code above has two scripts.
353
354 <img src="images/script-tags.png"
355 alt="Including Dart apps in HTML">
356
357 The first includes your mini app.
358 It uses two attributes: `type` indicates the type of the script.
359 `application/dart` is a new type created by the Dart team,
360 which is currently supported by Dartium.
361 The `src` attribute provides the URL to the source file of the script.
362 In this case, it is the Dart source file `mini.dart` that you created earlier.
363 The Dart file should be in the same directory as its host HTML file.
364
365 The second `script` tag is
366 a bootstrap script that takes care of turning on the Dart VM,
367 as well as compatibility with non-Dart browsers.
368
369 This diagram summarizes the connection
370 between `mini.dart` and `mini.html`. 342 between `mini.dart` and `mini.html`.
371 343
372 <img src="images/dart-html-connect.png" 344 <img src="images/dart-html-connect.png"
373 alt="The connection between the HTML file and the Dart file"> 345 alt="The connection between the HTML file and the Dart file">
374 346
375 ##Run the mini web app {#run-mini} 347 ##Run the mini web app {#run-mini}
376 348
377 In Dart Editor, 349 In Dart Editor,
378 make sure that one of `mini`'s files or the directory is selected, 350 select `mini.html` and then click the Run button
379 and then click the Run button
380 <img src="images/run.png" width="16" height="16" 351 <img src="images/run.png" width="16" height="16"
381 alt="Run button">. 352 alt="Run button">.
382 Dart Editor invokes Dartium 353 Dart Editor invokes Dartium
383 and loads `mini.html` in it. 354 and loads `mini.html` in it.
384 Below is mini app running in a frame. 355 Below is mini app running in a frame.
385 The app just displays a line of text. 356 The app displays the text provided by Dart code,
357 namely "Wake up, sleepy head!",
358 not the text provided in the HTML file.
386 359
387 <iframe class="running-app-frame" 360 <iframe class="running-app-frame"
388 style="height:150px;width:300px;" 361 style="height:150px;width:300px;"
389 src="http://dart-lang.github.io/dart-tutorials-samples/web/target02/mini /web/mini.html"> 362 src="examples/mini/mini.html">
390 </iframe> 363 </iframe>
391 364
392 The Dart web app changed 365 The Dart web app changed
393 the text in the browser window dynamically at runtime. 366 the text in the browser window dynamically at runtime.
394 Of course, placing static text on a browser page 367 Of course, placing text on a browser page
395 and doing nothing else 368 and doing nothing else
396 could be accomplished with straight HTML. 369 could be accomplished with straight HTML.
397 This little app only shows you how to make a connection 370 This little app only shows you how to make a connection
398 from a Dart app to a browser page. 371 from a Dart app to a browser page.
399 372
400 ##Create a JavaScript launch {#mini-with-js}
Kathy Walrath 2013/10/08 21:25:22 Shouldn't you teach them how to run it as a JavaSc
401
402 You can create various runtime scenarios for your Dart app
403 using *launches* in Dart Editor.
404 A launch specifies a runtime configuration,
405 such as whether to compile to JavaScript
406 or what browser to use.
407
408 In this section,
409 you will create a launch for mini that first compiles the app to
410 JavaScript and then runs it in the default system browser.
411
412 <ol>
413 <li markdown="1">
414 In Dart Editor,
415 click the wee arrow to the right of the run button
416 <img src="images/run.png" width="16" height="16"
417 alt="Run button">.
418 A menu appears:
419
420 <img src="images/manage-launches-menu.png"
421 alt="Manage launches menu">
422
423 You have been unwittingly using launches when running
424 the samples so far.
425 The menu item `mini.html from mini` is a launch that Dart Editor
426 automatically created
427 when you ran the application for the first time
428 in the previous section.
429 </li>
430
431 <li markdown="1">
432 Select **Manage launches** from the menu
433 to bring up the **Manage Launches** dialog.
434 Using the small icons,
435 you can create launches for different purposes:
436
437 <img src="images/new-launch-menu.png" alt="Launch options">
438
439 By default,
440 Dart Editor automatically creates a Dartium launch for web apps.
441 You must explicitly create a Dart JavaScript launch
442 to create a runtime configuration that compiles
443 your web app to JavaScript and then runs it in a browser.
444 </li>
445
446 <li markdown="1">
447 Click the JavaScript launch icon
448 <img src="images/dart2js-icon.png" width="18" height="17"
449 alt="JavaScript launch icon">.
450 The dialog window adjusts to present the appropriate options
451 for your selection.
452 </li>
453
454 <li markdown="1">
455 Name the launch by typing `mini-with-js` in the first text box.
456
457 <img src="images/new-js-launch.png"
458 alt="Create a launch that compiles to JavaScript">
459
460 It is recommended that the launch name reflect
461 the important aspects of its configuration.
462 In this case, the launch name specifies the app name
463 and that it's a JavaScript launch.
464 If the launch specified a browser, such as FireFox,
465 you might name the launch `mini-with-js-in-firefox`.
466 </li>
467
468 <li markdown="1">
469 The launch target is the HTML file `mini.html`.
470 Browse to the file.
471 </li>
472
473 <li markdown="1">
474 Click **Apply**.
475 The named launch should now appear
476 in the list to the left of the window.
477
478 <img src="images/mini-with-js-item.png"
479 alt="New named launch in the list of launches">
480
481 </li>
482
483 <li markdown="1">
484 To run the launch,
485 click the Run button at the bottom right of the window.
486 Or select it from the Run menu on the main Dart Editor window.
487
488 This time, Dart Editor
489 creates a JavaScript file,
490 invokes the default system browser
491 and loads the JavaScript file into it.
492 The output should look the same.
493 </li>
494
495 </ol>
496
497 ##Give the app some style with CSS {#add-css} 373 ##Give the app some style with CSS {#add-css}
498 374
499 Most HTML uses cascading style sheets (CSS) to define _styles_ 375 Most HTML uses cascading style sheets (CSS) to define _styles_
500 that control the appearance of page elements. 376 that control the appearance of page elements.
501 Let's customize the CSS for the mini app. 377 Let's customize the CSS for the mini app.
502 378
503 In Dart Editor, edit the file named mini.css 379 In Dart Editor, edit the file named `mini.css`
504 and replace the contents of the file with 380 and replace the contents of the file with
505 the following CSS code: 381 the following CSS code:
506 382
507 {% prettify dart %} 383 {% prettify dart %}
508 #RipVanWinkle { 384 #RipVanWinkle {
509 font-size: 20px; 385 font-size: 20px;
510 font-family: 'Open Sans', sans-serif; 386 font-family: 'Open Sans', sans-serif;
511 text-align: center; 387 text-align: center;
512 margin-top: 20px; 388 margin-top: 20px;
513 background-color: SlateBlue; 389 background-color: SlateBlue;
514 color: Yellow; 390 color: Yellow;
515 } 391 }
516 {% endprettify %} 392 {% endprettify %}
517 393
518 This defines a style 394 This defines a style
519 for the page element 395 for the page element
520 with the ID RipVanWinkle. 396 with the ID RipVanWinkle.
521 To use this style sheet, 397 To use this style sheet,
522 edit mini.html and add the line shown in bold below: 398 edit `mini.html` and add the line shown in bold below:
523 399
524 <img src="images/html-with-css.png" 400 <img src="images/html-with-css.png"
525 alt="HTML with CSS"> 401 alt="HTML with CSS">
526 402
527 Save your files and run the app again. 403 Save your files and run the app again.
528 404
529 Below is the revised mini app, 405 Below is the revised mini app,
530 which is slightly more colorful 406 which is slightly more colorful
531 but still neither interactive nor interesting. 407 but still neither interactive nor interesting.
532 408
533 <iframe class="running-app-frame" 409 <iframe class="running-app-frame"
534 style="height:150px;width:300px;" 410 style="height:150px;width:300px;"
535 src="http://dart-lang.github.io/dart-tutorials-samples/web/target02/mini _with_style/web/mini_with_style.html"> 411 src="examples/mini_with_style/mini_with_style.html">
536 </iframe> 412 </iframe>
537 413
538 ##About CSS selectors {#about-css-selectors} 414 ##About CSS selectors {#about-css-selectors}
539 415
540 IDs, classes, and other information about elements 416 IDs, classes, and other information about elements
541 are established in HTML. 417 are established in HTML.
542 Your Dart code can use this information 418 Your Dart code can use this information
543 to get elements using a CSS selector&mdash;a pattern 419 to get elements using a CSS selector&mdash;a pattern
544 used to select matching elements in the DOM. 420 used to select matching elements in the DOM.
545 CSS selectors allow the CSS, HTML, and Dart code 421 CSS selectors allow the CSS, HTML, and Dart code
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 alt="A declaration specifies an attribute and its value"> 486 alt="A declaration specifies an attribute and its value">
611 487
612 The CSS rule for the RipVanWinkle paragraph 488 The CSS rule for the RipVanWinkle paragraph
613 specifies several properties; 489 specifies several properties;
614 for example, it sets the text color to Yellow. 490 for example, it sets the text color to Yellow.
615 491
616 ##Other resources 492 ##Other resources
617 493
618 <ul> 494 <ul>
619 <li> 495 <li>
620 <a href="/docs/dart-up-and-running/">Dart Up and Running</a> 496 <a href="/docs/dart-up-and-running/">Dart Up and Running</a>
Kathy Walrath 2013/10/08 21:25:22 Technically it's "Dart: Up and Running" (colon po
mem 2013/10/09 17:07:31 Done.
621 provides thorough coverage of the Dart language, libraries, and tools. 497 provides thorough coverage of the Dart language, libraries, and tools.
622 If a topic is not covered explicitly here, 498 If a topic is not covered explicitly here,
623 you can find the information you need there. 499 you can find the information you need there.
624 </li> 500 </li>
625 <li> 501 <li>
626 <a href="/docs/dart-up-and-running/contents/ch04-tools-editor.html">Dart Edi tor</a>, 502 <a href="/docs/dart-up-and-running/contents/ch04-tools-editor.html">Dart Edi tor</a>,
627 an excerpt from <em>Dart Up and Running</em>, 503 an excerpt from <em>Dart Up and Running</em>,
Kathy Walrath 2013/10/08 21:25:22 ditto
mem 2013/10/09 17:07:31 Done.
628 provides details about using Dart Editor. 504 provides details about using Dart Editor.
629 The excerpt includes, for example, 505 The excerpt includes, for example,
630 how to use Dart Editor's power features such as autocompletion and refactori ng, 506 how to use Dart Editor's power features such as autocompletion and refactori ng,
631 how to set up different run-time environments, and so on. 507 how to set up different run-time environments, and so on.
632 </li> 508 </li>
633 <li> 509 <li>
634 Also, check out 510 Also, check out
635 <a href="/docs/cookbook/"> 511 <a href="/docs/cookbook/">
636 <i class="icon-food"> </i> Dart Cookbook</a>, 512 <i class="icon-food"> </i> Dart Cookbook</a>,
637 where you'll find many recipes about 513 where you'll find many recipes about
638 manipulating the DOM and using CSS. 514 manipulating the DOM and using CSS.
639 The cookbook also has recipes about basic Dart data types, 515 The cookbook also has recipes about basic Dart data types,
640 such strings, lists, maps, and numbers. 516 such strings, lists, maps, and numbers.
641 </li> 517 </li>
642 </ul> 518 </ul>
643 519
520 ##What next?
521
522 The next tutorial, [Add Elemens to the DOM](/docs/tutorials/add-elements/),
Kathy Walrath 2013/10/08 21:25:22 Elemens -> Elements
mem 2013/10/09 17:07:31 Done.
mem 2013/10/09 17:07:31 Done.
523 shows you how to dynamically change the HTML page
524 by adding elements to the DOM.
525
644 {% endcapture %} 526 {% endcapture %}
645 527
646 {% include tutorial.html %} 528 {% include tutorial.html %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698