Top Banner
Sponsored by Upsilon Pi Epsilon The Computer Science Honors Society
43

HTML & CSS Workshop Notes

May 06, 2015

Download

Technology

Pamela Fox

Put on by USC's Upsilon Pi Epsilon as part of Wonderful World of Web2.0 Workshop Series.
http://pollux.usc.edu/~upe/
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: HTML & CSS Workshop Notes

Sponsored byUpsilon Pi Epsilon

The Computer Science Honors Society

Page 2: HTML & CSS Workshop Notes

Upsilon Pi Epsilon

•UPE is the Computer Science Honors Society.

•It is a national honors society, with over 120 University Chapters around the country.

•“New” to USC

Page 3: HTML & CSS Workshop Notes

•Workshop series around web 2.0 technologies

•This is the first of many

•Future topics will include: Javascript, PHP, Ruby on Rails, and more.

•Send us your ideas!

Page 4: HTML & CSS Workshop Notes

What is Web 2.0?

Page 5: HTML & CSS Workshop Notes
Page 6: HTML & CSS Workshop Notes

“Web 2.0, a phrase coined by O'Reilly Media in 2004, refers to a supposed second-generation of Internet-based services — such as social networking sites, wikis, communication tools, and folksonomies — that let people collaborate and share information online in previously unavailable ways.”

- Wikipedia (a Web 2.0 organization)

Page 7: HTML & CSS Workshop Notes

Why should I care?

Page 8: HTML & CSS Workshop Notes
Page 9: HTML & CSS Workshop Notes

What We’ll Cover Today

•HTML (Hypertext Markup Language)

•DOM (Document Object Model - briefly)

•CSS (Cascading Style Sheets)

Page 10: HTML & CSS Workshop Notes

HTML

Page 11: HTML & CSS Workshop Notes

History of HTML

•Tim Berners-Lee created first HTML version in the late 1980s (as a subset of SGML)

•Needed a simple way to share research among colleagues; piggy backed off newly evolving Internet (previously just text)

•HTML spread as multiple proprietary versions; in 1993 the IETF published a working draft of the first “official” HTML

Page 12: HTML & CSS Workshop Notes

History of HTML Part 2

•Simplicity made things easy for people new to computers and publishing

•Also left the “code” a mess, leaving every browser to handle different mistakes in its own way

•Soon, the World Wide Web Consortium (W3C) was created to draft a set of standards for all web browsers to adhere to

Page 13: HTML & CSS Workshop Notes

History of HTML Part 3

•Features were added to HTML very quickly: tables, colors, backgrounds, fonts, etc.

•Web sites started becoming very complex

• It became impossible to manage all the HTML tags needed to style the content on multiple sites, code bases starting becoming huge, tables were being used to make better designs... things got ugly.

Page 14: HTML & CSS Workshop Notes

History of HTML Part 4

•We needed a solution to this problem, and that solution was CSS.

•With the revolution of Cascading Style Sheets, HTML (and later XHTML) became about describing content, not presentation

•The look of a web page (the presentation) was left entirely to style sheets, which could be common to entire sites

Page 15: HTML & CSS Workshop Notes

Setting up a web “Presence”

• No point to a website if no one else can see it...

• USC lets every student create a web presence on the aludra.usc.edu server

• If you don't have it setup yet:

• telnet aludra.usc.edu

• type requestwww

• follow the instructions

Page 16: HTML & CSS Workshop Notes

Setup Part 2

• To see your web presence, point browser to http://www-scf.usc.edu/~username

• To upload files to your web account, use an FTP client

• You can download COREFTP(PC) or Fetch(Mac) from usc.edu/software or poke around your PC for an app with "FTP" in title

• Login to aludra.usc.edu with usual USCWeb login

• Upload files to public_html folder

Page 17: HTML & CSS Workshop Notes

HTML: What is it?

•HTML stands for Hyper Text Markup Language

•An HTML file is a text file containing small markup tags

•The markup tags tell the Web browser how to display the page

•An HTML file can be created using a simple text editor or a WYSIWIG editor

Page 18: HTML & CSS Workshop Notes

Hello World!

<html><html><head><head><title>Hello World!</title><title>Hello World!</title></head></head><body><body>Hello World!Hello World!</body></body></html></html>

Page 19: HTML & CSS Workshop Notes

HTML Basics: Tags/Attributes

• HTML tags are used to mark-up HTML elements

• Tags are surrounded by the two characters < and >, which are called angle brackets

• Tags normally come in pairs like <b> and </b>. The text between the start and end tags is the element content

• Tags are not case sensitive, <b> means the same as <B>, but use lowercase: you’ll find out its better

• Tags often have attributes, which gives the browser additional information about displaying the element

• Attributes come in name-value pairs, with the value in double or single quotes (e.g. <img width=”100px”>)

Page 20: HTML & CSS Workshop Notes

HTML Basics:Formatting Tags

• In HTML, formatting is not based on whitespace! (example)

• Use tags to format text:

• <p></p> - paragraph tag, optional align attribute

• <br> - line break tag

• <b></b> or <strong></strong> - boldface tag, <strong> is more standards-compliant now

• <i></i> or <em></em> - italics tag, <em> is more standards-compliant now

• <ul><li>blabla 1</li> .. </ul> - unordered list tag, creates bulleted list, can be nested

• <ol><li>blabla 1</li> .. </ol> - ordered list tag, creates numbered list, can be nested

Page 21: HTML & CSS Workshop Notes

HTML Basics: Hyperlinks &

Images• Anchor tag can be used to create hyperlink or define an

anchor within a page

• <a href="http://www.google.com">google</a> - creates hyperlink, optional target, title attributes, URL can be relative or absolute

• <a name="section2"></a> - creates anchor in page

• <a href="index.html#section2">section2</a> - to link to in-page anchor

• <img src="URL.gif"> - creates image, optional width/height attributes, alt attribute to provide alternate text, align attribute to specify around-text wrapping, border attribute

• Image tags can be nested in hyperlink tags to create hyperlinked images

Page 22: HTML & CSS Workshop Notes

HTML Basics: Tables/Frames

• Both of these are considered evil nowadays.

• Before <DIVS> were introduced, people used tables to layout websites (e.g. multi-column website)

• The HTML for tables is obtuse and prone to corruptibility (just try looking at the source of a fully tabled website)

• But it exists...and could be occasionally useful

• <table></table> - creates table, optional width/height/align/bgcolor attributes

• <tr></tr> - creates table row with the same attribute options

• <td></td> - creates table cell with the same attribute options

• Frames: web-designers used to use frames to separate the navigation page from the site's content (e.g. all CS websites!)

• Frames are generally a bad idea... http://www.karlcore.com/articles/article.php?id=2 So we won't tell you tags for them.

Page 23: HTML & CSS Workshop Notes

HTML Basics: Forms

• Very common on the web as they provide interactivity

• <form></form> - defines form, optional method/name/action attributes to tell browser where to send results when submit pressed

• <input></input> - generic input tag, used always with type attribute to specify type (checkbox, radio, text, submit), also optional name/value attributes

• <textarea></textarea> - multi-line text area input, optional rows/cols attributes

• <select> <option>op1</option> ... </select> - creates combo/dropdown box

Page 24: HTML & CSS Workshop Notes

HTML Basics: Colors

• HTML Basics: Color

• Color is used extensively in HTML: text color, background color, border color, link color, hr color, etc

• Only 16 color names are approved by W3C - aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow

• All other colors should be referred to by Hexadecimal codes (#RRGGBB)

• Always pick a pleasing color scheme for your site

• Color references: http://w3schools.com/html/html_colors.asp http://www.degraeve.com/color-palette/ http://wellstyled.com/tools/colorscheme2/index-en.html http://wellstyled.com/tools/colorscheme2/index-en.html http://www.siteprocentral.com/cgi-bin/feed/feed.cgi

Page 25: HTML & CSS Workshop Notes

HTML Basics: References

•http://w3schools.com/html/default.asp

•http://w3schools.com/html/html_quick.asp

•http://webmonkey.com/webmonkey/reference/html_cheatsheet/

•http://www.htmlcodetutorial.com/

•http://validator.w3.org/

Page 26: HTML & CSS Workshop Notes

Standards

•Read the W3C Specs! Search them!

•Use the W3C Validator!

•Write valid XHTML Strict/Transitional (or HTML 4.1) whenever possible (always!)

•Separate content and presentation: use style sheets to change the look of your site!

Page 27: HTML & CSS Workshop Notes

Document Object Model

•A graph representation of the structure of an HTML/XHTML document

•An API for accessing and interacting with the graph and its elements

•The key ingredient to DHTML, AJAX, and this whole Web 2.0 thing

•Visualizer: http://www.aharef.info/static/htmlgraph/

Page 28: HTML & CSS Workshop Notes

CSS

Page 29: HTML & CSS Workshop Notes

Cascading Style Sheets

•A standard method of applying style and appearance information to text and other elements of a web page

•Cascading means that properties “cascade” down through all child elements of a given element

Page 30: HTML & CSS Workshop Notes

Selectors•Style sheets are made up

of individual style elements that define size, color, fonts, etc.

•Each style has a unique name: a selector

•Selectors refer to specific elements, or sets of elements, in your (X)HTML files

Page 31: HTML & CSS Workshop Notes

Pseudo Selectors

•pseudo selectors can select specific parts of an element, or elements with specific properties

•allows us to create :hover effects

Page 32: HTML & CSS Workshop Notes

Syntax• C style syntax

• almost never need the @media type declaration, but it is very useful to know - can target different types of devices easily

• adding a background color to the body:

body {background: red;

}

Page 33: HTML & CSS Workshop Notes

Style Sheets

• To style a webpage, you need lots of individual selectors and styles

• Create style sheets to contain all of these style definitions

• add them to your page a number of ways:

• <link rel=stylesheet href="whatever.css" type="text/css">

• <style type=”text/css”> @import: url(aStyle.css) </style>

• or declare styles right in the style tag

Page 34: HTML & CSS Workshop Notes

CSS Layout•There are two types of elements in the

CSS world: box level elements, and inline elements

•tags that would normally cause a newline in html are generally block level elements

•<div> is the empty box element

•text it usually inline content

•<span> is the empty inline element

•Any element can be told to be a box

Page 35: HTML & CSS Workshop Notes

CSS Positioning•There are a few different ways to

position box elements:

•position•absolute•fixed•relative

•float - most people are confused by this!• left•right

Page 36: HTML & CSS Workshop Notes

Box Model

Page 37: HTML & CSS Workshop Notes

CSS Properties

http://www.ilovejackdaniels.com/css_cheat_sheet.pdf

Page 38: HTML & CSS Workshop Notes

Demo

Page 39: HTML & CSS Workshop Notes

Considerations

•CSS does not behave as expected if your (X)HTML is not well formed: VALIDATE!

•There are more tags that you will ever memorize, so look things up with google

•CSS is complex - go home, read about it online, try things out. The best way to learn is probably to look at existing web pages CSS and see what does what

•Oh, and its not exactly a standard...

Page 40: HTML & CSS Workshop Notes

CSS Standards•CSS is a W3C standard

•Unfortunately, Internet Explorer decided not to implement the standard the correct way

•Generally, you will have to “hack” your CSS to get it to work the way you want in IE

•Furthermore, there are multiple levels of support, and every browser varies on this

Page 41: HTML & CSS Workshop Notes

CSS References•http://www.ilovejackdaniels.com/css

_cheat_sheet.pdf

•http://www.w3.org/Style/CSS/

•http://www.w3schools.com/css/

•http://www.csszengarden.com

•http://meyerweb.com/eric/css/edge/

•http://jigsaw.w3.org/css-validator/

Page 42: HTML & CSS Workshop Notes

Questions?

Page 43: HTML & CSS Workshop Notes

Contact

•Pamela Fox: [email protected]

•Ross Boucher: [email protected]

•UPE: [email protected]

•On the web: http://pollux.usc.edu/~upe/