O'Reilly logo

Learning Web App Development by Semmy Purewal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. The Style

In the previous chapter, we learned to structure the content of an HTML document and some related mental models. But the pages we created left a lot to be desired in terms of design and style.

In this chapter, we’ll attempt to alleviate some of these issues and learn to change the way an HTML document is displayed using Cascading Style Sheets (CSS). As mentioned in the previous chapter, this will give you enough information to get started with CSS, and More Practice and Further Reading will encourage you to explore other resources.

Hello, CSS!

To get our feet wet, we’ll start with a very simple HTML example, similar to the ones from the beginning of the previous chapter. Open up a terminal window and create a directory called Chapter3 in our Projects directory.

Now open up Sublime Text, and open the Chapter3 directory in the same way that we did in the previous chapter. Create the following HTML file and save it in the directory as index.html:

<!doctype html>
<html>
  <head>
    <title>My First Web App</title>
    <link href="style.css" rel="stylesheet" type="text/css">
  </head>

  <body>
    <h1>Hello, World!</h1>

    <p>This is a paragraph.</p>
  </body>
</html>

This file defines a very simple HTML page with an h1 element and a p element contained in the body element. You’ll immediately notice that the example also includes a new tag contained inside the <head> tag. The <link> tag links to an external stylesheet file that describes how the document should be displayed.

You can create the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required