HTML5 and CSS3 Part 1: Using HTML and CSS to Create a Website Layout Fall 2011, Version 1.0
Total Page:16
File Type:pdf, Size:1020Kb
CALIFORNIA STATE UNIVERSITY, LOS ANGELES INFORMATION TECHNOLOGY SERVICES HTML5 and CSS3 Part 1: Using HTML and CSS to Create a Website Layout Fall 2011, Version 1.0 Table of Contents Introduction ....................................................................................................................................3 Downloading the Data Files ..........................................................................................................3 Requirements..................................................................................................................................3 About Notepad++ ........................................................................................................................3 About HTML and CSS ..................................................................................................................4 HTML5 .......................................................................................................................................4 Basic HTML Tags ..................................................................................................................4 HTML Tag Syntax .................................................................................................................5 Head and Body Tags ..............................................................................................................5 CSS ..............................................................................................................................................5 CSS Syntax .............................................................................................................................5 ID and Class Selectors ............................................................................................................5 CSS Selectors .........................................................................................................................6 Creating a New Web Page .............................................................................................................6 Creating a Home Page .................................................................................................................6 Basic Web Page Structure ......................................................................................................7 Indentation .........................................................................................................................7 Adding a Page Title ................................................................................................................7 Saving and Viewing the Web Page ........................................................................................8 Adding an Internal Style Sheet ...................................................................................................8 Setting the Background Color ................................................................................................8 Creating a Wrapper .....................................................................................................................9 Creating a Class for the Wrapper ...........................................................................................9 Checkpoint One .........................................................................................................................10 Creating the Web Page Structure within the Container ..........................................................10 Adding a Banner .......................................................................................................................10 Adding a Navigation Bar ..........................................................................................................11 Checkpoint Two ........................................................................................................................11 Adding the Main Content Containers ........................................................................................12 Adding the Main Content ..........................................................................................................12 Adding the Footer .....................................................................................................................13 For additional handouts, visit http://www.calstatela.edu/handouts. For video tutorials, visit http://www.youtube.com/mycsula. Adding Text to the Web Page .....................................................................................................13 Checkpoint Three ......................................................................................................................14 Basic Styling of Text .................................................................................................................14 Appendix .......................................................................................................................................15 HTML5 and CSS3 Part 1: Using HTML and CSS to Create a Website Layout 2 Introduction Websites can be created by using one of many programming languages (e.g., HTML, JSP, PHP, ASP, ASP.NET, or Perl). Among those languages, HTML is the most basic text-based language that has been used in web design since 1989. HTML consists of two parts: 1) content that will be displayed in a web browser, and 2) markup or tags, which are encoded information that are generally hidden from web page viewers. This three-part handout will help users create a basic website using fundamental HTML knowledge that they can build on with more advanced techniques. The first part covers web design basics, including the use of divisions to arrange the page layout, menu bar to link multiple pages, and CSS3 to enhance web page elements. Downloading the Data Files This handout includes sample data files that can be used for hands-on practice. The data files are stored in a self-extracting archive. The archive must be downloaded and executed in order to extract the data files. The data files used with this handout are available for download at http://www.calstatela.edu/its/training/datafiles/html5p1.exe. Instructions on how to download and extract the data files are available at http://www.calstatela.edu/its/docs/download.php. Requirements A text editor, preferably Notepad++ or something similar. Notepad that is provided with Windows will also work. Notepad++ − http://notepad-plus-plus.org/download − http://portableapps.com/apps/development/notepadpp_portable (Portable version that can be placed on a flash drive) A current web browser (e.g., Mozilla Firefox, Google Chrome, or Internet Explorer 9). Mozilla Firefox http://www.mozilla.com/en-US/firefox/new/ . Google Chrome http://www.google.com/chrome/intl/en/landing_chrome.html?hl=en . Internet Explorer 9 (Only on Windows 7 and Windows Vista Service Pack 2) http://windows.microsoft.com/en-US/internet-explorer/downloads/ie NOTE: Anything below Internet Explorer 9 is not compatible with the new HTML5 features. While any on the list above is acceptable, this handout was developed based on the steps administered in Notepad++ and Mozilla Firefox. About Notepad++ Notepad++ is a lightweight, but powerful text editing tool (see Figure 1). It is built primarily for programming, not writing essays. It has built-in tag highlighting and automatic indentation which helps improve organization and readability. HTML5 and CSS3 Part 1: Using HTML and CSS to Create a Website Layout 3 Figure 1 – Notepad++ Program Window About HTML and CSS HyperText Markup Language (HTML) and Cascading Style Sheets (CSS) are two of the core technologies for building web pages. HTML is the language for describing the structure of web pages. CSS is the language for describing the presentation of web pages, including colors, layout, and fonts. The separation of HTML from CSS makes it easier to maintain websites and share style sheets across web pages. HTML5 HTML5 is still a work in progress and has been since June of 2004. Most of the tags that were compatible in previous versions of HTML are still compatible. However, they are no longer used because better and cleaner methods have since been found. HTML5 is still not final, but is already making a huge impact on the web. Basic HTML Tags HTML uses tags to describe the structure of web pages. Web browsers use the tags in an HTML document to interpret the content and display it as a web page. For every HTML based web page, there are several tags that are always inserted into the document: <!doctype>, <html>, <head>, <title>, and <body> (see Figure 2). Figure 2 – Source Code for a Blank HTML Page HTML5 and CSS3 Part 1: Using HTML and CSS to Create a Website Layout 4 HTML Tag Syntax HTML tags are keywords surrounded by angle brackets (< and >). HTML tags normally come in pairs (e.g., <body> and </body>). The first tag in a pair is called the opening tag, and the second tag is called the closing tag. The opening tag consists of the tag name enclosed in angle brackets (e.g., <body>). The closing tag is the same as the opening tag except it has a forward slash (/) before the tag name (e.g., </body>). Head and Body Tags Web pages are divided into two sections: the head and the body. The head section is where you define the title of the web page, provide metadata about the page (e.g., keywords, character encoding), add style sheets, and insert scripts. The body section encloses the contents of the web page, the part that your visitors will see, including text, hyperlinks,