17
Laying out an HTML document

03 html layout

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: 03 html layout

Laying out an HTML document

Page 2: 03 html layout

Good HTML has four elements

� DOCTYPE � html � head � body

Page 3: 03 html layout

The DOCTYPE declaration

� This DOCTYPE says to draw the page normally <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">!

� Here's the one for HTML5 <!DOCTYPE html>!

Page 4: 03 html layout

The <html> tag wraps the entire page

Page 5: 03 html layout

The <head> tag contains the metadata for the page � <script> � <style> � <title> � <meta>

Page 6: 03 html layout

The <body> tag

Contains all of the markup that is displayed on the page.

Page 7: 03 html layout

Altogether it may look like this <!DOCTYPE html>!<html>! <head>! …! </head>! <body>! …! </body>!</html>!

Page 8: 03 html layout

There are several basic, must-know tags

� <!-- --> � <p> � <br /> � <a> � <img>

Page 9: 03 html layout

Commenting your HTML

<!-- This is a comment -->!

Page 10: 03 html layout

The <p> tag is for text only

� <p> … </p> � Creates a line break before and after

Page 11: 03 html layout

<br /> creates a line break

�  It is a singleton tag <p>!

Kreese: Sweep the leg.<br />!

[Johnny stares at him in shock]<br />!

Kreese: Do you have a problem with that?<br />!

Johnny Lawrence: No, Sensei. <br />!

Kreese: No mercy. !

</p>!

Page 12: 03 html layout

The anchor tag allows hyperlinking � Allows linking from section to section and

page to page. � Link to another page: <a href=http://www.othersite.com/>Go to other site</a>!

� Link to someplace on this page: <a href="#aParagraph">Go to another paragraph.</a>!

� … and … <a name="aParagraph"></a>!

� Email link: <a href=mailto:[email protected]>Email Rap</a>!

Page 13: 03 html layout

Add images with <img>

�  Inserts an image. <img src="logo.jpg" />!

�  Formats allowed: jpg, gif, png � Can specify sizes and alternate texts: <img src="logo.jpg" alt="Company logo" height="52px" width="100px" />!

�  alt text for missing/jank images and vision-impaired surfers

� Can make it a link, too: <a href="tic.com"><img src="logo.jpg" /></a>!

Page 14: 03 html layout

Hands-on HTML layout

Page 15: 03 html layout

There are many other tags for layouts

� We'll get to these in a few chapters. �  div �  span �  nav �  article �  aside �  header �  footer �  hgroup �  time � mark

Page 16: 03 html layout

Conclusion

� The basic layout of a page contains exactly one each of a DOCTYPE declaration, a html tag, a head tag, and a body tag

� You'll also need paragraph tags to wrap text, line breaks, and probably anchor tags

Page 17: 03 html layout

Further study