AP CS P. Unit 2. Introduction to HTML and CSS

Similar documents
Downloads: Google Chrome Browser (Free) - Adobe Brackets (Free) -

Html basics Course Outline

11. HTML5 and Future Web Application

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

Web Development and HTML. Shan-Hung Wu CS, NTHU

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

Hyper Text Markup Language

Web Programming BootStrap Unit Exercises

CSS worksheet. JMC 105 Drake University

Web Technology. Assignment 3. Notes: This assignment is individual assignment, every student should complete it by himself.

This document provides a concise, introductory lesson in HTML formatting.

Unit 5 Web Publishing Systems Page 1 of 13 Part 4 HTML Part 4

Introduction to WEB PROGRAMMING

Which is why we ll now be learning how to write in CSS (or cascading sheet style)

week8 Tommy MacWilliam week8 October 31, 2011

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

Creating A Web Page. Computer Concepts I and II. Sue Norris

Hyper Text Markup Language

The Benefits of CSS. Less work: Change look of the whole site with one edit

HTML and CSS: An Introduction

ITNP43: HTML Lecture 4

The internet is a worldwide collection of networks that link millions of computers. These links allow the computers to share and send data.

Purpose of this doc. Most minimal. Start building your own portfolio page!

Anatomy of an HTML document

HTML & CSS. Rupayan Neogy

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

CSS: Cascading Style Sheets

Introduction to Cascading Style Sheet (CSS)

How the Internet Works

CREATING A WEBSITE USING CSS. Mrs. Procopio CTEC6 MYP1

Revision for Grade 7 ASP in Unit :1&2 Design & Technology Subject

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

The Structure of the Web. Jim and Matthew

HTML, CSS, JavaScript

WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5

Stamp Builder. Documentation. v1.0.0

First Name Last Name CS-081 March 23, 2010 Midterm Exam

HTML and CSS COURSE SYLLABUS

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

Building Your Website

CSS.

CSS means Cascading Style Sheets. It is used to style HTML documents.

Using Dreamweaver CS6

HTMLnotesS15.notebook. January 25, 2015

CSS: The Basics CISC 282 September 20, 2014

CS 350 COMPUTER/HUMAN INTERACTION. Lecture 6

To link to an external stylesheet, the link element is placed within the head of the html page:

Web Publishing Basics I

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) More on Relative Linking. Learning Objectives (2 of 2)

Programmazione Web a.a. 2017/2018 HTML5

HTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية

Block & Inline Elements

Lab 1: Introducing HTML5 and CSS3

Dreamweaver Domain 5: Organizing Content by Using Dreamweaver CS5

Introduction to HTML and CSS. Arts and Humanities in the Digital Age 2018 CHASE DTP Dr. Paul Gooding

COSC 2206 Internet Tools. CSS Cascading Style Sheets

<body bgcolor=" " fgcolor=" " link=" " vlink=" " alink=" "> These body attributes have now been deprecated, and should not be used in XHTML.

Using Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles

HTML & CSS Cheat Sheet

Eng 110, Spring Week 03 Lab02- Dreamwaver Session

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

CSS - Cascading Style Sheets

Chapter 7 BMIS335 Web Design & Development

Responsive Web Design and Bootstrap MIS Konstantin Bauman. Department of MIS Fox School of Business Temple University

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application.

MODULE 2 HTML 5 FUNDAMENTALS. HyperText. > Douglas Engelbart ( )

Figure 1 Properties panel, HTML mode

Beginning HTML. A tag is a command written between angle brackets (the less than and greater than symbols). Ex. <html>

What is CSS? NAME: INSERT OPENING GRAPHIC HERE:

A HTML document has two sections 1) HEAD section and 2) BODY section A HTML file is saved with.html or.htm extension

Data Visualization (DSC 530/CIS )

Markup Language. Made up of elements Elements create a document tree

AGENDA. EMBEDDING FONTS [ Font Files & CSS font-family ] :: Online Font Converter :: ADD font-family css code to style.css

Creating and Building Websites

CSS THE M\SS1NG MANUAL. David Sawyer McFarland. POGUE PRESS" O'REILLr Beijing Cambridge Farnham Köln Paris Sebastopol Taipei Tokyo

Cascading Style Sheets Level 2

('cre Learning that works for Utah STRANDS AND STANDARDS WEB DEVELOPMENT 1

HTML & CSS. Lesson 1: HTML Basics Lesson 2: Adding Tables Lesson 3: Intro to CSS Lesson 4: CSS in more detail Lesson 5: Review

COMP519 Web Programming Autumn Cascading Style Sheets

Web Designing HTML5 NOTES

INTRODUCTION TO HTML5! HTML5 Page Structure!

Data Visualization (CIS/DSC 468)

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

Website Development with HTML5, CSS and Bootstrap

What is a web site? Web editors Introduction to HTML (Hyper Text Markup Language)

In the early days of the Web, designers just had the original 91 HTML tags to work with.

Using CSS in Web Site Design

CSS: Cascading Style Sheets

recall: a Web page is a text document that contains additional formatting information in the HyperText Markup Language (HTML)

COPYRIGHTED MATERIAL. Contents. Chapter 1: Creating Structured Documents 1

Tutorial. Activities. Code o o. Editor: Notepad Focus : Text manipulation & webpage skeleton. Open Notepad

Hyper Text Markup Language HTML: A Tutorial

COMP519 Web Programming Lecture 3: HTML (HTLM5 Elements: Part 1) Handouts

Session 5. Web Page Generation. Reading & Reference

Introduction to Web Technologies

Web Programming and Design. MPT Senior Cycle Tutor: Tamara Week 1

GRAPHIC WEB DESIGNER PROGRAM

Microsoft Expression Web Quickstart Guide

**Method 3** By attaching a style sheet to your web page, and then placing all your styles in that new style sheet.

Transcription:

AP CS P. Unit 2. Introduction to HTML and CSS HTML (Hyper-Text Markup Language) uses a special set of instructions to define the structure and layout of a web document and specify how the document should be displayed in a browser. Initially developed around 1990, HTML has gone through several revisions. This focuses on HTML 5. Ex. 1 Go to repl.it and sign up. If given a choice, select New Web Repl. Otherwise, we are selecting HTML/CSS/JS. Eventually your screen should look like the one below. We will not have time to cover JavaScript in this unit so delete index.js and replace the statement: <script src="index.js"></script> with Hello World index.html should now look like this: <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>repl.it</title> <link href="index.css" rel="stylesheet" type="text/css" /> Hello World Do the following: Click the run button and see your page displayed in the result tab. Click ( Open in a new tab ) to see the page displayed in its own tab. Leave this tab open. Change <title>repl.it</title> to <title>your name</title> and refresh your page that is in its own tab. Add more text after Hello Word. Right-click on the page and select view page source 1

Some vocabulary and explanations <blah> something something </blah> An normally consists of an opening, a closing, and whatever comes between them. Some elements consist of a single tag. For example: <meta charset="utf-8"> Our web pages will follow the following format: (Technically not a tag) Exactly one html element <html> <head> information about the page meta tags provide metadata about the web page content Exactly one body element Exactly one head element <html> <head> <meta charset="utf-8"> defines the character encoding scheme used * <meta name="viewport" content="width=device-width"> <title>repl.it</title> <link href="index.css" rel="stylesheet" type="text/css" /> Hello World to be explained later to be explained later * Very good article, from 2003, about this. The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developerabsolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/ 2

HTML file contains tags and content The browser (e.g. Chrome, Firefox, etc.) software reads the file and displays the content. Hello World Paragraph and Heading Elements. Ex. 2 italics. Change the content between the body tags to the following. You should customize anything in <h1>your Name s Home Page</h1> <p>this is a work in progress</p> <h2>monday</h2> <p>say something about Monday (lots of words so it wraps around)</p> <p>say something else about Monday (lots of words so it wraps around)</p> <h2>tuesday</h2> <p>say something about Tuesday (lots of words so it wraps around)</p> <p>say something else about Tuesday (lots of words so it wraps around) </p> View the contents in a separate tab. Do the following and then answer the questions below. Remove all line breaks from the above code so that it looks this: <h1>your Name s Home Page</h1><p>This is a work in progress</p><h2>monday</h2><p>say something about Monday. </p><p>say something else about Monday. </p><h2>tuesday</h2><p>say something about Tuesday. </p><p>say something else about Tuesday. </p> Refresh your web page to see what effect these changes made. Add lots of spaces and line breaks randomly throughout the source code but NOT in the tags. The result could look something like this: <h1>your Name s Home Pa ge </h1><p>t h i s is a work in progress</p> <h2> Monday</h2> <p>say something a b out M on day. </p> <p> Say something else about Monday. </p> <h2> T used ay </h2> <p> Say something a bout Tuesday. </p> <p>say something else abo ut Tuesday. </p> The term whitespace refers to spaces, new line characters (from hitting the Enter key), and tabs. If there are five whitespace characters in a row in the source code, the TRUE FALSE browser only displays one. Line breaks in the source code are treated as spaces by the browser when it TRUE FALSE comes to determining what to display. If there are 3 consecutive whitespace characters in a row, the browser TRUE FALSE deletes two of those characters from the source code. A paragraph element always starts on a new line. TRUE FALSE A heading element does NOT always start on a new line. TRUE FALSE 3

There are six heading elements. <h1> is supposed to be the most important heading; <h6> the least important. If we use the analogy of a text book <h1> would be used for the title of the book <h2> would be for each chapter in the book <h3> would be for each major section in each chapter and so. Here is an interesting article about these tags: https://www.hobo-web.co.uk/headers/ IMPORTANT. Do NOT use h1, h2, etc. just to make something bold or larger than other text. Good websites use HTML tags to identify the purpose/meaning of the content - not for stylistic reasons. CSS (Cascading Style Sheets) is the proper technology to use to determine how to display a web page. Ex. 3 Clean up the content in the body element so it looks something like what we had at the beginning of exercise 2. Then add the following to the index.css file. index.css body of the html page body{ <h1> text</h1> background-color: LightGoldenRodYellow ; <p>text text text text text text text text text <h2>text</h2> p{ <p>text text text text text text text text text color:darkslategray ; <p>text text text text text text text text text h1, h2{ <h2>text</h2> font-size: 20px; <p>text text text text text text text text text text-align: center; font-weight: normal; <p>text text text text text text text text text color:darkslategray ; Run/update the web page. Notice that as you change the width of the page, the heading elements stay centered. Your browser has a default style sheet for determining how to display the body elements. Your CSS file overrides those default styles. Each CSS statement follows this format selector { attribute : value; attribute : value; The selector determines which elements style is being defined. For now, the selector is an element or list of elements but there are more options. There are many different attributes to choose from and generally many different values and ways to express those values. We will just scratch the surface of CSS in this unit. 4

Ex. 4 Go to https://www.w3schools.com/css/default.asp. We will be using this site a lot. Look at the CSS Colors section and change the background color of the body and color of the text in the headings and paragraphs. Notice that colors can be specified in a number of ways. Look at the CSS Fonts section and change the font that is used for the paragraphs. For practice sake, use a different font family for the headings. See the note below about fonts. Increase the font size of all elements. Important: you should specify a list of fonts as in this example: p { font-family: "Times New Roman", Times, serif; This means that the browser will first try to use Times New Roman. If that font is not supported, it will try Times. If that is not supported, it will use a generic serif font. The list of font types should be similar. This list gives some common combinations: https://www.w3schools.com/cssref/css_websafe_fonts.asp Links. The following exercise will show you how to link to other sites as well as other pages in your own web site. Ex. 5 Create a new file and name it page2.html Copy the code below into index.html and page2.html index.html page2.html <html><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>your name</title> <link href="index.css" rel="stylesheet" type="text/css" /> <h1>home Page</h1> This is a <a href="page2.html">link to page 2</a>. <html><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>your name</title> <link href="index.css" rel="stylesheet" type="text/css" /> <h1>welcome to Page 2</h1> <p>yes, this is page 2.</p> Click <a href="index.html">here</a> to go to the home page. Click <a href ="https://www.w3schools.com/default.asp"> here</a> to go to W3Schools. Inside the <a> tag is an attribute-value pair href= url of another page href is the attribute. The value is either an absolute address (full URL) or relative address. The value should always be in quotes. Also notice that the <a> does not generate line breaks because it is considered an in-line element. Block elements, such as <p> and <h1>, do generate line breaks. Ex. 6 Modify your website so that you have a total of three different html pages. Add links so that users can move from one page to the other. On one of the pages you should have a list of at least three useful/fun/random links to other sites. One of the links to be to another classmate s repl.it website. 5

Comments are good way to hide additional information in the source code without it effecting how the page is displayed. In html, a comment looks like this <!-- whatever text you want. It can span over multiple line --> < followed by! followed by two hyphens --- (with no spaces) comments two hyphens followed by > Ex. 7 Add a comment to your index page, on the line just below the doctype declaration. The comment should include your first name, last initial, the date you added the comment, and whatever else you re in the mood to enter. Ex. 8 View your index.html in its own tab on your desktop computer or laptop. Then view it on your phone or a classmate s phone. It should look a little different on your phone but still good. Next, comment out the meta tag that mentions name and viewport. When done, it should look like this: <!-- <meta name="viewport" content="width=device-width"> --> Refresh the page on the desktop computer. It should not look much different. Refresh the page on your phone. Oh boy! There are many techniques to designing a webpage that looks good on different sized devices. The above meta tag helps some and that s why it s there. Please uncomment it. Images. Here is an example of how to display an image. <img src="square.png" alt="purple square"> It is a single tag with two attribute-value pairs. The first pair identifies the image and second pair provides a brief text description of the image. In a separate worksheet you will explore and learn about the basics of copyrights public domain copyrights and fair use creative commons Bottom line regarding using graphics, audio, video, or anything that someone else created. Always give credit where credit is due. If explicit permission is required, get it or don t use the material. For this course, you must indicate where you got your graphics. Put a link or comments near the graphics. If that makes your page look bad, then put this information in a comment in your code. Ex. 9 Create a new html file and display three images. Each image should be on its own line and centered on the page. Do this by wrapping each <img> tag in a paragraph element. Then use CSS to center anything in a paragraph (which, of course, is usually text but this time is a picture). Be sure to identify where you got each picture. If these are all pictures you took with your phone or drew, be sure to say that. ALSO, turn the last picture into a link to another site (whichever site makes sense to you). While I did not explicitly tell you how to do that, you can figure it out. 6

CSS Classes. Up to this point, when we applied a CSS style to an HTML element, it applied to all of those elements. For example, p { color: red; makes the text in all paragraphs red. If you need only some of the paragraphs to be red, do this:.red-text { The CSS class name is arbitrary but cannot contain a space. color: red; The period at the start is NOT part of the name. Then, change the appropriate paragraph elements by adding an attribute-value pair as follows: Somewhere in the body element <p class="red-text">this text is red.</p> <p>this text is not red.</p> <p class="red-text">this text is red.</p> <p>this text is not red.</p> Notice that the class name does not include the period. Ex. 10 Create a page similar to the one below. There are 7 paragraphs, one h1 heading, and two h2 headings. The CSS file has two class selectors. One displays the text in italics and one displays it underlined. You can find how to do that under the CSS Text and CSS Font sections of W3Schools CSS tutorials. 7

Ordered and Unordered Lists. HTML elements are supposed to reflect the meaning of the content. For instance, an h1 element is supposed to indicate a major topic of the page. It is not supposed to be used because the designer wants the text to be big and bold - that s what CSS is for. The idea of a list is a collection of related items. If the order of the items is important (e.g. they are directions), then use an ordered list. <p>directions from C168 to Mr. Savitz's room</p> <ol> <li>turn left out the door.</li> <li>go up the steps.</li> <li>his room is about 30 feet down the hall on your right.</li> </ol> An unordered list looks the same except that we begin and end with <ul> and </ul> instead of <ol> and </ol> <p>actual standard color names in CSS</p> <ul> <li>tomato</li> <li>burlywood</li> <li>papayawhip</li> </ul> Ex. 11 Create web page that contains an unordered list of favorite websites. Use CSS to change the default look. There s an example to the right. Div Tags were introduced as a way of grouping related, adjacent elements together. It is a nonsemantic element because it tells you nothing about the meaning of its content. They are designed to be used with CSS styles. Here s a very brief example. <div> text and other elements. </div> HTML 5 introduced many more descriptive tags that should be used in place of div tags but div tags are still used in a lot of different situations. They are simple to use. 8

Ex. 12 Create the page below. There is one h1 element, two h2 elements, four paragraphs (the first one is wrapped around the link), and one div element. The div element has a border and a colored background. 9