Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

CSS Basics

Before we talk about anything new there are a few fundamentals we need to take care of, such as how to place CSS on your site and how to select specific styles for specific devices (iPhone or iPad).

Using Your CSS

Question: Do you embed your CSS in your page or externalize it (put it in a separate .css file)?

Answer: Sometimes for testing I put the CSS in my page where I can have visibility to all the rules and properties, but this generally isn't a good idea because it makes CSS rules less reusable and more difficult to maintain. Inline CSS looks like this:

<head>
<style>
header,nav,footer,article,section {margin:5px;}
header,nav,footer {border:1px solid #000;}
section {border:1px dotted green;}
</style>
</head>

When you want to externalize your CSS there are two ways: one is to link your document via the <link> tag, and the second is to import your document via the @import rule.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint