CS174
Chris Pollett
Aug 29, 2022
ISO HTML (HTML 4.01) which is specified using SGML a XHTML 1.0 Transitional XHTML 1.0 STRICT XHTML 1.1 HTML 5/XHTML 5 HTML LS
<img src="my_picture.png" ></img> <!-- this is okay in an XHTML document (not in HTML 5). BTW, this is an example HTML comment --> <img src="my_picture.png" /> <!--this is okay for both XHTML and HTML 5 and is an abbreviation for the line above --> <img src="my_picture.png" > <!--okay only in HTML 5, but don't use for this class --> <P>old style paragraph</P> <!--okay only in HTML 5, but don't use for this class --> <p><i>Hello</i></p> <!--okay --> <p><i>Hello</p></i> <!--not okay -->Open tags may have attributes. For example, src in the image tag above. The value of an attribute must be given in double quotes or single quotes for XHTML. Quotes are optional for HTML 5.
Which of the following is true?
XML declarations:
<?xml version ="1.0" encoding="utf-8" ?> <!-- as not supported by some old browsers validators doesn't usually check this -->
SGML DOCTYPE. This says which Document Type Definition will be used:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
The XHTML document:
<html xmlns="http://www.w3.org/1999/xhtml" > <!-- might have namespaces for other things like SVG --> <head> <title>name of my document</title></head> <body><!--actually page stuff--></body> </html>
<!DOCTYPE html> <html lang="en" > <head> <title>Simple HTML</title> <meta charset="utf-8" /> </head> <body> <h1>Example HTML 5 document.</h1> <p>Example paragraph.</p> </body> </html>
We have now looked at a simple HTML document. This consisted of a DOCTYPE declaration, an html tag pair with head and body tag pairs as its contents. The head has to have at least a title tag within it. Let's now examine what can go in the head and body tags pairs in detail, beginning by looking at the head tag:
Examples: <link rel="stylesheet" type="text/css" href="http://somewhere.com/css/search.css" /> <link rel="icon" href="http://www.cs.sjsu.edu/faculty/pollett/favicon.ico" /> <link rel="prev" href="./?LecList.php" />
Example: <base href="http://www.my.com/stuff/" />Now a link <a href="file.html" >file</a> would have the implicitly base address in front of it.
Heads of documents can also have (but are not required to have) meta tags.
<meta name="author" content="who wrote the page" /> <meta name="generator" content="ChrisTextTool" /> <!--What software was used to generate this html --> <meta name="description" content="how I would like the search engines to describe my page. " /> <meta name="keywords" content="cool site" /> <!--Key terms search engines should index this site with. Unfortunately, not really used by search engines anymore --> <meta name="robots" content="comma separated list of what would like crawler to do" /> <!-- Example commands NOINDEX, NOFOLLOW, NOCACHE, NOSNIPPET, NOODP, NOYDIR . Some of these commands can also be specified in a robots.txt file. ROBOTS and these values are case insensitive.-->
Rather than use robots in the above you can also give directives for specific robots.
In addition to the above meta tags, we will see later in the semester how aspects of how the screen renders in a mobile phone can be affected by meta tags.
The WHATWG Meta Extensions page contains a relatively complete list of values for the name and content attribute.
<meta http-equiv="foo" content="bar" />is treated by a browser as if the response header field:
foo: barwas sent.
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Expires" content="Wed, 30 Aug 2006 14:25:27" /> <meta http-equiv="refresh" content="10;url=http://www.cs.sjsu.edu/" />