VISA/APCO/STAC 2P61 WEBSITE CREATION Fall Term 2012 ______
Total Page:16
File Type:pdf, Size:1020Kb
VISA/APCO/STAC 2P61 WEBSITE CREATION Fall Term 2012 __________________________________________________________________________________ GETTING STARTED WITH XHTML AND CSS Do you have the book recommended for this course? HTML and CSS Web Standards Solutions A Web Standardistasʼ Approach Christopher Murphy and Nicklas Persson If you donʼt have the recommended book please find another. You will need something to refer to. If not the book…here are some websites where you can find good tutorials for writing standards based XHTML and CSS http://www.w3.org/MarkUp/Guide/ http://www.w3.org/MarkUp/2004/xhtml-faq http://www.htmldog.com http://xhtml.com/en/xhtml/reference/ http://www.webheadstart.org/xhtml/basics/index.html http://daringfireball.net/projects/markdown/ http://www.alistapart.com/ HTML Hypertext markup language Create with range of tools – plain text editor (with formatting turned off) Will be read by variety of devices Designed to be read by web browsers Non proprietary Open source Free Structures text to hyperlinks W3C 1995 first specs written. Current is 4.0 written in 1999 (HTML 5 in the works) XHTML XML (no defined tags like HTML – has defined structure) Extensive Markup Language Is HTML reformatted in XML HTML with strict rules of XML Varieties of XHTML – 1.0 Strict, (we use this one) 1.0 Transitional, 1.0 Frameset 1 The value of Standards • Avoid (as much as possible) sites that wonʼt display as written • More accessible sites • XHTML and CSS written to strict standards • Enables site to perform predictably on any standards compliant browser or OS • Improves Development time • Ease of updating • Search engine ranking XHTML/CSS Separates Content from Visual presentation/design Avoids Tag Soup of HTML where tags were used to control both how content is structured and how it looks. (HTML never intended to be used for design – it was designed for semantic (meaning imparting) markup of info – not visual effects. XHTML for content, structure and meaning CSS for visual presentation and design XHTML AND CSS REPRESENT A SYSTEMATIC APPROACH TO WEB DEV IN CONTEXT OF EVER CHANGING TECHNOLOGY. It is important to master each step and move on PLEASE SUPPRESS URGE TO RUSH AHEAD AND TO DESIGN Like other disciplines (music or martial arts) – master fundamentals before fancy moves. Well structured markup in XHTML of equal importance to CSS and design It will be daunting at first but once you know it will empower you . Tools No WYSIWYG drag and drop environment, No buttons to click No software writing markup behind scenes 1. Browser view source (in view menu) 2. Plain text editor Text Wrangler on our computers For others see www.webstandardistas.com/tools BASIC HTML TAGS HTML describes the different elements that the webpage consists of You write tags as you write content in TextWrangler and use Browser to open that file and see. 2 CRAWL BEFORE YOU WALK FUNDAMENTAL TAGS AND CONCEPTS TO KNOW: • 2 most basic HTML elements <head> <body> • nesting of tags • Title <title> • Headings <h1> <h2> etc. • Paragraphs <p> and • Lists <ul> and <ol> • Tables <tr> • How semantic tags that add info • Images <img> tag Principle 1. Tags Tags describe all elements and give structure to the page Tags are distinguished from content by the angle brackets <p> This is the content of the page </p> The material inside the brackets (e.g. <p> doesnʼt display It give browser info on how the document is interpreted All tags are in lower case <h1> not <H1> All tags have opening and closing <p> …………..</p> (note: early days, browsers would guess at invalid markup - do its best or second guess. Standards today require well formed markup to get the page you intend. Principle 2. HTML element = Start tag < > content End tag </> Principle 3. HTML naming 1. filename.html – html is a suffix for file extension It tells browser the document is a web page (some use .htm from the old days when PCʼs used only 3 letter extensions) 2. No spaces in file names 3. Use an underscore _ in place of a space (alt is a hyphen -) 4. Use lower case and not capitals wherever possible. Principle 4. The basic structure of any HTML page <html> - tells browser this is a HTML document <head> - tells browser this is information “about” the page – e.g. the title <title> - tells browser the title to display at the top of the browser page <body> - tells browser this is the start of information to be displayed on page itself <p> - surrounds paragraphs (in this case just one phrase Hello World </p> closes paragraph tag </body> closes body tag </html> closes html tag 3 Learn from seeing other peopleʼs source code. Open www.webstandardistas.com/02/king_kong_junior.html Go to View -> View Source Might now look unintelligible but soon it will be super instructive. ALL HTML PAGES HAVE THE FOLLOWING: <head>………………….</head> - info about doc. Not part of actual content includes page title that will appear at top of window and metatags that provide info about page for search engines. It also give info about style sheets. <body>…………………</body> - everything youʼll see in window text, links, images, etc. <title> element <head> element will contain title element so browser window will have a name (other than the name.html). If no title browser will display name.html <title> improves usability and search rankings think of our shoes site styles.html vs Types and Styles I Shoes in Culture Document Type Comes before <head> Defines the set of rules browser much use for interpreting your doc. e.g. HTML 4.0 Strict HTML 4.0 Transitional XHTML 1.0 Strict XHTML 1.0 Transitional XHTML 1.0 Frameset Document Type Definition (DTC) = DOCTYPE <!DOCTYPE html PUBLIC “/ /W3C/ /DTD XHTML 1.0 Strict/ /EN” http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd> • This tells browser how to display and what language of markup is used. • This needs to be before opening <html> tag • If itʼs not included browser will revert to QUIRKS MODE e.g. default to old fashioned quirky markup interpretation that allows the browser to guess when tags are malformed or when the browser might not have the same standards. This allows older pages to display in newer standards compliant browsers. Adding DOCTYPE avoids any confusion also add: name space declaration. It is part of <html> opening and it insures page validates 4 <html xmlns=http://www.w3c.org/1999/xhtml> <meta http-equiv =“Content-Type” content=”text/html; charset=UTF-8” /> more later on metatags. Go to www.webstandardistas.com/02/template.html to get this View Source <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Insert Your Title Here</title> </head> <body> <p>Replace this content with your own.</p> </body> </html> It wonʼt make your page look different but it is what you need to make sure your page is correct. STRUCTURE OF TAGS NESTING ELEMENTS – ONE ELEMENT WITHIN ANOTHER <html> l <head> <body> I I <title> </title> <p> </p> I l </head> </body> l </html> Valid XHTML requires proper nesting e.g. <title within <head> </head> tags Need to close tags in order that they are opened – first in last out e.g <p> <strong> <em> I am a paragraph. I am emphasized. I am also strongly emphasized. </em> </strong> </p> Comments Not everything in an HTML doc displays e.g. <head> XHTML allows hidden elements in head and body. These can only be seen in View Source <!! - - opens a comment - - > closes it 5 Everything between will be hidden in the browser Can use this to help you find your way. • Remind you why you structured the code a certain way • Provide a note regarding a change in the document • Leave a note to collaborators • Prepare code and content to use later (can remove the comments and reactivate code) White Space Use of line breaks, tabs and space to separate sections of your code to make it easier to read. Browsers wonʼt see this. XHTML GIVES A WEBSITE STRUCTURE AND MEANING Principle – POSH (Plain Old Semantic HTML) Creates structure Creates semantics – signposts for reading – like headings and emphasis To fully understand this we need to set aside desire to “design” for now BUT without realizing it – using structure and semantic markup means design is creeping in. STRUCTURED MARKUP = SEMANTIC MARKUP • Defines content • Organizes structure • This is part of design process • Beginning designers go wrong by missing this and rushing to make things look good. STRUCTURE – TAGS Use right one for right job – based on content. e.g. It defines what is a heading It starts with careful analysis of content Headings <h1> <h2> etc. guide the eye through content. Headlines of differing sizes signify importance. Example headings.html Whatʼs more important h1 or h2. – h1 most -- h6 least Paragraphs <p> sits under headings Helps reader skim Should convey doc structure Do not skip through hierarchy Do not use <h> tags to create visual effects 6 Application of Information Hierarchy CASE STUDY http://www.corpse.org Look at use of headings (skip past menus) Headings separate lots of info What is most important on page? What is most important story? Look at news h1 and h2 (are they all same importance?) H3 where is that? Stories on right – less urgent? Two approaches to markup of heads Linear – h2 is subsection of h1 Less linear – based on importance H2 is not sub part of h1 – it is just less important Content is the guide PHRASE ELEMENTS nested in <p> </p> tag Remember basic elements Start tag content End tag < > text text text text text </ > Elements can contain other elements (nesting) Everything is within the <body> </body> element A phrase element – adds meaning to text <em> <strong> nested in <p> </p> element convey meaning (or help screen readers know when to change volume or pitch) rather than as design feature like <i> or <b> which are Presentational.