XHTML References and Rules William Pegram Revised 9/15/2015.

9
XHTML References and Rules William Pegram Revised 9/15/2015

Transcript of XHTML References and Rules William Pegram Revised 9/15/2015.

Page 1: XHTML References and Rules William Pegram Revised 9/15/2015.

XHTML References and Rules

William PegramRevised 9/15/2015

Page 2: XHTML References and Rules William Pegram Revised 9/15/2015.

Reminders

• Filenames and foldernames should not have spaces in them

• All the content of the webpage should go between the <body> and </body>

• Things in between <head> and </head>– <title> - required for validation– <style> - embedded stylesheet (optional)– <link> - for external stylesheets (optional)– <meta> - meta tags (optional)– <script> - JavaScript (optional; can also be in body)

Page 3: XHTML References and Rules William Pegram Revised 9/15/2015.

References to Other Files

• HTML/XHTML files often contain references to other files. Examples of such references are:– Links– Images (inline, background, and favicon)– External stylesheets– Flash movies– Video and audio using the new <video> and

<audio> HTML5 tags– External JavaScript files

Page 4: XHTML References and Rules William Pegram Revised 9/15/2015.

Ways of Referencing Other Files

• Absolute using http:// -- this is the only way to reference files on other websites

• Relative – the location of the file is specified relative to the location of the file in which the reference is contained

• Absolute using a beginning / (Dreamweaver calls these site-root references) – one specifies the path to the file beginning with the top level (root) of the site

Page 5: XHTML References and Rules William Pegram Revised 9/15/2015.

Relative References• If both files are in the same folder, just specify

the filename• If in different folders, do like in the following

example – Suppose you have a folder named redskins and at the top level of this folder you have files called allen.html and shanahan.html, a folder named offense and a folder named defense

• in the offense folder there is a file called mcnabb.html and in the defense folder there is a file called haynesworth.html

Page 6: XHTML References and Rules William Pegram Revised 9/15/2015.

Folder structure

[Some folder containing the following]allen.htmlshanahan.html[offense folder which contains the following file]

mcnabb.html[defense folder which contains the following file]

haynesworth.html

Page 7: XHTML References and Rules William Pegram Revised 9/15/2015.

Relative references• From the shanahan.html file, references to the

other files would be written as follows:<a href="allen.html">General Manager</a>

<a href="offense/mcnabb.html">QB</a>From the mcnabb.html file, references to the other

files would be written as follows:<a href="../shanahan.html">Coach</a>

<a href="../defense/haynesworth.html">Albert</a>

• The ../ takes you up one level, out of current folder; it can be repeated multiple times ../../ for up two levels, etc.

Page 8: XHTML References and Rules William Pegram Revised 9/15/2015.

Use of leading / in reference

• If the reference begins with a / rather than a ../, the / means to start at the top level of the site.

• While this may seem like a simpler way to do the reference, the leading / has several disadvantages:– The reference can't be tested locally (i.e. File>Open)– What is the root of the site can depend on where the

site is hosted, so the site becomes less portable than if the reference were relative

Page 9: XHTML References and Rules William Pegram Revised 9/15/2015.

XHTML Rules

• All tags and attribute names lowercase• Attribute values must be in double quotes• No one-sided tags – use /> to end such tags• Attributes must be set equal to values, thus in a radio

button or checkbox you can't just used checked, but must say checked="checked" Thus instead of writing

<input type="checkbox" name="day" checked>One writes<input type="checkbox" name="day" checked="checked"

/>