WELCOME TO BEGINNING CSS: Cascading Style Sheets for Web Design, Third Edition
Cascading Style Sheets (CSS) are the tool that web designers and developers use alongside markup languages such as HTML and XHTML to build websites. CSS provides web browsers with the information they need to control the visual aspect of a web page, such as the position of HTML elements, text styles, backgrounds, colors and images, and much more.
Advanced CSS techniques give website authors the ability to tailor layouts and designs for mobile web browsers, as well as the skills they need to create websites for regular desktop browsers. I will introduce you to the basics of writing CSS for mobile devices.
The second edition of this book, written entirely by Richard York, provides very thorough and complete coverage of CSS at the time of its writing. Possibly no other CSS book for beginners goes into so much detail and depth.
For the third edition, I have taken Richard's work and streamlined it to focus on the techniques that professional authors of CSS use every day to create the wide range of sites on the Web today. My intention is to provide an introduction to CSS that is easy to dive into and enables you, the reader, to get up, running, and productive with CSS as quickly as possible.
Many of the words you will read are Richard's, but I have attempted to mould them around my own experience as a long-time author of CSS used on websites big and small, complex and simple.
While some attention is paid to the older browsers still in use today, I have chosen to spend more time on the newer crop of browsers and those likely to be significant in the future, providing you with up-to-date knowledge and skills.
The code in all of the examples is syntax highlighted for easy readability, and the exercises that you will encounter are inspired by real-world uses of CSS and HTML, helping you to write CSS in the right way from the start.
I encourage you to have fun with each exercise, learning not only by following my instructions, but also by experimenting with the properties and values that I introduce you to.
This book is for anyone looking to learn how to use Cascading Style Sheets to style websites. Designers, in particular, will benefit from a good grounding in CSS, as it is the key to producing websites from their designs.
To get the most from this book, experience with HTML is useful. While all of the HTML you need to follow the examples is provided, you will gain a greater understanding of the best methods for using CSS to create websites if you already know how to write markup.
This book covers portions of the CSS Level 1, 2, 2.1, and 3 specifications. These specifications are created by an independent, not-for-profit Internet standards organization called the World Wide Web Consortium (W3C) that plans and defines how Internet documents work. The majority of the book is written using what is defined in the CSS Level 2.1 specification, with a sprinkling of CSS 3 to make things interesting.
This book leads you through how to write CSS so that it is compatible with all of the most popular web browsers. I have focused on all of the following popular browsers:
The preceding browsers make up over 99 percent of the web browser market share at the time of this writing. For your convenience, this book also includes an integrated CSS feature reference throughout the book, as well as notes on browser compatibility. A CSS reference is also included in Appendix C.
This book is divided into three parts. The following explains each of these three parts in detail, and what each chapter covers.
Throughout Chapters 1 through 4, you learn the founding principles of CSS-based web design.
Throughout Chapters 5 through 13, you learn about properties that are used to manipulate the presentation of a document.
In Part II, I cover the basics; in Part III, we move on to advanced techniques, which give you more fine control when styling content, and show you how to style for different media types such as print and mobile, as well as introduce a few more properties.
The final part of the book is the Appendixes:
To make use of the examples in this book, you need the following:
Designing content for websites requires being able to reach more than one type of audience. Some of your audience may be using different operating systems or different browsers other than those you have installed on your computer. This book focuses on the most popular browsers available at the time of this writing.
I discuss how to obtain and install each of these browsers in Chapter 1. The examples in this book also require that web page source code be composed using text-editing software. Chapter 1 also discusses a few different options for the text-editing software available on Windows or Macintosh operating systems.
To help you get the most from the text and keep track of what's happening, I've used a number of conventions throughout the book:
WARNING Boxes like this one hold important, not-to-be-forgotten information directly relevant to the surrounding text.
NOTE The pencil icon indicates notes, tips, hints, tricks, and asides to the current discussion.
Examples that you can download and try out for yourself generally appear in a box like this:
TRY IT OUT
The Try It Out is an exercise you should work through, following the text in the book.
How It Works
After each Try It Out, the code you've typed will be explained in detail.
As for styles in the text:
We present code in two different ways:
We use a monofont type with no highlighting for most code examples. We use bold to emphasize code that is particularly important in the present context or to show changes from a previous code snippet.
Also, code editors like Notepad++ provide a rich color scheme to indicate various parts of code syntax. That's a great tool to help you learn language features in the editor and to help prevent mistakes as you code. The code listings in this book are colorized using colors similar to what you would see on screen in Notepad++ working with the book's code. In order to optimize print clarity, some colors have a slightly different hue in print than what you see on screen. But all of the colors for the code in this book should be close enough to the default Notepad++ colors to give you an accurate representation of the colors.
As you work through the examples in this book, you may choose either to type the code yourself or use the source code files that accompany the book. All the source code used in this book is available for download at www.wrox.com. When at the site, simply locate the book's title (use the Search box or one of the title lists) and click the Download Code link on the book's detail page to obtain all the source code for the book. All the Try It Out example code is included in the download files for the book at Wrox.com. In addition, any other code snippets that are included with the download files are highlighted by the following icon:
Code snippets include the filename as it appears in the download files in a code note such as this:
code snippet /path/filename
NOTE Because many books have similar titles, you may find it easiest to search by ISBN; this book's ISBN is 978-0-470-89152-0.
After you download the code, just decompress it with your favorite compression tool. Alternatively, you can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books.
We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be very grateful for your feedback. By sending in errata, you may save another reader hours of frustration, and at the same time, you will be helping us provide even higher quality information.
To find the errata page for this book, go to www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page, you can view all errata that has been submitted for this book and posted by Wrox editors.
NOTE A complete book list, including links to each book's errata, is also available at www.wrox.com/misc-pages/booklist.shtml.
If you don't spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport.shtml and complete the form there to send us the error you have found. We'll check the information and, if appropriate, post a message to the book's errata page and fix the problem in subsequent editions of the book.
For author and peer discussion, join the P2P forums at p2p.wrox.com. forums are a web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.
At http://p2p.wrox.com, you will find a number of different forums that will help you, not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:
NOTE You can read messages in the forums without joining P2P, but in order to post your own messages, you must join.
Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works, as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.
3.145.81.232