Learn CSS In One Day and Learn It Well
CSS for Beginners with Hands-On Project
The only book you need to start coding in CSS immediately
http://www.learncodingfast.com/css
Copyright 2015
All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law.
Preface
This book is written to help you learn CSS FAST and learn it WELL.
The book does not assume any prior background in coding. If you are an absolute beginner, you'll find that this book explains complex concepts in an easy to understand manner. If you are an experienced coder but new to CSS, this book will provide you with enough depth to start coding in CSS immediately.
All examples and images in the book are carefully chosen to demonstrate each concept so that you can gain a deeper understand of the language. Each CSS chapter also comes with an exercise at the end of the chapter. The exercises are designed to help you further strengthen your understanding. The source code for all the exercises can be found in the appendix at the end of the book.
In addition, as Richard Branson puts it: "The best way of learning about anything is by doing". This book comes with an additional bonus project where youll be guided through the coding of a webpage entirely from scratch. The project uses concepts covered in the book and gives you a chance to see how it all ties together.
You can download the bonus project and the source code for all the exercises at
http://www.learncodingfast.com/css .
Contact Information
I would love to hear from you.
For feedback or queries, you can contact me at .
More Books by Jamie
Python: Learn Python in One Day and Learn It Well
Table Of Contents
Chapter 1: Introduction
Welcome to the world of CSS. I am so glad and honoured that you picked up this book. Before we embark on this learning journey together, let us first define what is CSS.
CSS stands for Cascading Stylesheet and is used for the styling and design of a website. It is one of the many languages a web programmer uses to create a website. Other web languages include HTML, Javascript and PHP, just to name a few.
HTML is concerned with the content and structure of a website. As a websites existence is meaningless without content, knowing HTML is essential for anyone interested in web programming. This book will first start with an introduction to HTML, covering some of the essential basics you need to know about HTML. While this coverage is by no means comprehensive, it should be enough for you to perform most of the HTML tasks necessary. If you are familiar with HTML, feel free to skip to Chapter 3.
Tools of the Trade
Before we start coding our HTML and CSS pages, let us first look at some of the recommended tools for doing web programming.
At the most basic level, you only need a web browser (e.g. Internet Explorer, Chrome, Safari, Firefox) and a text editor (e.g. Notepad) to start coding websites. However, unless you belong to the school of thought that real programmers shouldnt use any programming aid, I strongly encourage you to use some of the free tools available online to make your coding life easier.
One of the most recommended tool is an advanced text editor that offers syntax highlighting. Syntax highlighting means the editor will display text in different colors depending on the purpose of the text. For instance, the editor may use red color for keywords, blue for comments and green for variables. This simple feature will make your code much easier to read and debug. If you are on a Windows machine, I suggest Notepad++ (http://notepad-plus-plus.org/). For Mac, I suggest TextWrangler (http://www.barebones.com/products/textwrangler/). Both are free to use.
Opening a .HTML File
An .HTML file can be opened in two ways. One way is to open it in a web browser by double clicking on the file. This is for viewing the page. Another way is to open it in a text-editor for editing. To do that, first launch your text-editor and then open the file from within the editor.
When working with HTML files, I suggest you open the file in your browser and text-editor concurrently and arrange the two windows so that they are side-by-side. That way, you can edit the code on your editor, save it, and then move over to your browser, refresh the page and immediately check the effects of the changes you made to the code. Follow this procedure when working on the exercises from Chapters 3 to 10.
Chapter 2: Basics of HTML
Now that weve covered a basic introduction to web programming, lets start learning some actual HTML code. In this chapter, well be covering the essentials of HTML. If you are familiar with HTML, you can skip the chapter and go ahead to Chapter 3.
For those of you who are new to HTML, lets get started.
What is HTML
HTML stands for Hypertext Markup Language and is a language used by web programmers to add content to a web page. A markup language is simply a language for annotating a document to explain what different sections of the text are and how they should be presented. For instance, we can use HTML to specify whether the content should be presented as a list or in table form. The current HTML version is HTML5.
The nicest thing about HTML is that the source code of a web page is free for all to view. This makes it easy for us to learn HTML by studying the codes of other web pages. To view the source code of a web page on Windows, simply right-click anywhere on the page and select View Source (or something similar, such as View Page Source, depending on the browser you use). If you are on Mac, click on View in the menu bar, select Developer and then select View Source.
Most of the source code that you view will look very complicated, especially if you have no prior knowledge in HTML. Dont worry about that. Soon, youll be able to write such complicated codes yourself.
To get a better understanding of how HTML5 works, lets start by examining the basic structure of a HTML document.
Basic Structure of a HTML Page
An example of a basic HTML document is shown below. Ive added numbers beside each line of the code for easy reference. These numbers are not part of the actual code.
This is just text
8
As you can see from the code above, HTML uses a lot of angle brackets with a single word enclosed inside, such as
and . These are known as tags and each tag has a specific meaning in HTML.Doctype
On line 1, the tag tells the browser that this document uses HTML5. If you check the source of older web pages, you may see something like " http://www.w3.org/TR/html4/strict.dtd "> . This means they are using other versions of HTML, such as HTML4.01 in this case.
Start and End Tags
On line 2, the tag tells the browser that the actual HTML code starts here. Most tags in HTML have a corresponding end tag. The end tag for the tag is found on line 10. It has an additional forward slash (/) before the word html .
Note that not all tags in HTML have end tags. For instance, the tag, which is used to add images to our webpage does not have an end tag. Generally, there is a need for an end tag when we need to let the browser know where the effect of the tag should end. For instance, if we want to bold some text in HTML, we can write
This text is
Next page