SlideShare a Scribd company logo
1 of 45
My name is @mintran ,[object Object],[object Object],[object Object],I am
Writing beautiful HTML HTML ,[object Object],[object Object]
Beautiful HTML =  Semantic  <markup> <markup>
Web Standards are  not about using   DIV   for everything for everything for everything
<div>   stands for  DIVision Use DIV to create the site structure
<div id=”header”> </div> <div id=”left”> </div> <div id=”right”></div>
Avoid using DIV for decoration for decoration
[object Object],[object Object],[object Object],<h1> My headline  </h1> <h4> Sub headline </h4> <p> A paragraph </p> rather than
Multiple nested-DIVs  are  EVIL EVIL
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],this is EVIL
BE structural &   hierarchic O O O O O
[object Object]
[object Object],Use best practices
[object Object],Beautiful!
[object Object],[object Object]
[object Object],<p> this is a paragraph</p> <p> this is another paragraph</p>
[object Object],<h1> Site name </h1> <h2> Main Headline </h2> <h3> Normal Headline </h3> <h4> Sub headline </h4>
<ul>   for ,[object Object],[object Object]
<ul>   for ,[object Object],[object Object],<ol>   for ,[object Object],[object Object]
<ul> <li> <a href=&quot;#&quot;>Sign up</a> </li> <li> <a href=&quot;#&quot;>Login</a> </li> <ul> <ol> <li> Step 1: Pick a username </li> <li> Step 2: Pick a password </li> <li> Step 3: Enter your email address </li> <ol>
<dl>   for  pair values <dl> <dt> Name: </dt> <dd> Min Tran </dd> <dt> Website: </dt> <dd> http://www.frexy.com </dd> <dl>
Beautiful HTML =  meaningful & human-friendly  name convention
<h2 class= &quot;title&quot; >Main article</h2> <p class= &quot;summary&quot; >Article summary</h2> rather than <h2 class= &quot; blue &quot; > Main article </h2> <p class= &quot; green &quot; >Article summary</h2>
Recommendation: naming  classes  and  IDs  for their PURPOSE rather than APPEARANCE
Class  vs  ID
Use a class 1. The style is used in various places throughout the document. 2. The style is very general. <span class= &quot; alert &quot;> <span class= &quot; alert error &quot;> <h2 class= &quot; headline &quot;>
Use an ID 1. The style is only used once ever in the document. 2. The style is specific to a certain area of the document. <div id= &quot; header &quot;> <body id= &quot; home &quot;> <body id= &quot; home page &quot;>
ID  and  class   can be friends <li id= &quot; home &quot; class=&quot; current &quot;>
Beautiful HTML =  Separate presentation   from   the content the content the content
but HOW?
let’s create a photo gallery
turn on the X-ray machine leaves.jpg frame.gif
photos User add photos by editing html  or uploading via a CMS gallery
Photos are  content Drop shadows and borders are  presentation
content is user input data HTML should hold content only HTML should hold content only
<ul id=   &quot;gallery&quot;> <li> <img src=&quot;leaves.jpg&quot; /> </li> <li> <img src=&quot;balloon.jpg&quot; /> </li> <li> <img src=&quot;sea.jpg&quot; /> </li> <li> <img src=&quot;trees.jpg&quot; /> </li> <ul> HTML
#gallery { list-style:none; } #gallery li {  float:left; margin-right:20px; background:url(frame.gif) no-repeat; padding: 5px 5px 10px 5px; } #gallery img {  display:block; width:150px; height:150px; } CSS
STAY readable &   organized O O O O O
Use  <!--comment -->  to create separated code blocks to create separated code blocks
<!-- header --> <div id=&quot;header&quot;> ...  <div> <!-- end of header --> <!-- main --> <div id=&quot;main&quot;> ...  <div> <!-- end of main -->
use indent to improve  hierarchy
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],rather than
Conclusion ,[object Object],[object Object],[object Object],[object Object],[object Object]
HTML thật là điệp! Đúng dzồi! Đúng dzồi!

More Related Content

What's hot

La Educación y las Familias
La Educación y las FamiliasLa Educación y las Familias
La Educación y las FamiliasGuadalinfo Rus
 
Project 02 Creating and Editing a Web Page - Tags and Attributes
Project 02 Creating and Editing a Web Page - Tags and AttributesProject 02 Creating and Editing a Web Page - Tags and Attributes
Project 02 Creating and Editing a Web Page - Tags and AttributesAngela Edel
 
Vad är JQuery Mobile - Blixttal Mallis 2011
Vad är JQuery Mobile - Blixttal Mallis 2011Vad är JQuery Mobile - Blixttal Mallis 2011
Vad är JQuery Mobile - Blixttal Mallis 2011Fredrik Karlsson
 
Membuat CV dengan HTML
Membuat CV dengan HTMLMembuat CV dengan HTML
Membuat CV dengan HTMLDasufianti
 
Xml Xls ed Excel per la produzione espressa di Html - Chiara Bettaglio
Xml Xls ed Excel per la produzione espressa di Html - Chiara BettaglioXml Xls ed Excel per la produzione espressa di Html - Chiara Bettaglio
Xml Xls ed Excel per la produzione espressa di Html - Chiara BettaglioGirl Geek Dinners Milano
 
Learning To Love Forms (Web Directions South '07)
Learning To Love Forms (Web Directions South '07)Learning To Love Forms (Web Directions South '07)
Learning To Love Forms (Web Directions South '07)Aaron Gustafson
 

What's hot (10)

La Educación y las Familias
La Educación y las FamiliasLa Educación y las Familias
La Educación y las Familias
 
P Align=
P Align=P Align=
P Align=
 
Projeto Foto Blog Code
Projeto Foto Blog CodeProjeto Foto Blog Code
Projeto Foto Blog Code
 
Project 02 Creating and Editing a Web Page - Tags and Attributes
Project 02 Creating and Editing a Web Page - Tags and AttributesProject 02 Creating and Editing a Web Page - Tags and Attributes
Project 02 Creating and Editing a Web Page - Tags and Attributes
 
Vad är JQuery Mobile - Blixttal Mallis 2011
Vad är JQuery Mobile - Blixttal Mallis 2011Vad är JQuery Mobile - Blixttal Mallis 2011
Vad är JQuery Mobile - Blixttal Mallis 2011
 
Membuat CV dengan HTML
Membuat CV dengan HTMLMembuat CV dengan HTML
Membuat CV dengan HTML
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Xml Xls ed Excel per la produzione espressa di Html - Chiara Bettaglio
Xml Xls ed Excel per la produzione espressa di Html - Chiara BettaglioXml Xls ed Excel per la produzione espressa di Html - Chiara Bettaglio
Xml Xls ed Excel per la produzione espressa di Html - Chiara Bettaglio
 
Learning To Love Forms (Web Directions South '07)
Learning To Love Forms (Web Directions South '07)Learning To Love Forms (Web Directions South '07)
Learning To Love Forms (Web Directions South '07)
 
Código atividade 1
Código atividade 1Código atividade 1
Código atividade 1
 

Writing beautiful HTML

  • 1.
  • 2.
  • 3. Beautiful HTML = Semantic <markup> <markup>
  • 4. Web Standards are not about using DIV for everything for everything for everything
  • 5. <div> stands for DIVision Use DIV to create the site structure
  • 6. <div id=”header”> </div> <div id=”left”> </div> <div id=”right”></div>
  • 7. Avoid using DIV for decoration for decoration
  • 8.
  • 9. Multiple nested-DIVs are EVIL EVIL
  • 10.
  • 11. BE structural & hierarchic O O O O O
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20. <ul> <li> <a href=&quot;#&quot;>Sign up</a> </li> <li> <a href=&quot;#&quot;>Login</a> </li> <ul> <ol> <li> Step 1: Pick a username </li> <li> Step 2: Pick a password </li> <li> Step 3: Enter your email address </li> <ol>
  • 21. <dl> for pair values <dl> <dt> Name: </dt> <dd> Min Tran </dd> <dt> Website: </dt> <dd> http://www.frexy.com </dd> <dl>
  • 22. Beautiful HTML = meaningful & human-friendly name convention
  • 23. <h2 class= &quot;title&quot; >Main article</h2> <p class= &quot;summary&quot; >Article summary</h2> rather than <h2 class= &quot; blue &quot; > Main article </h2> <p class= &quot; green &quot; >Article summary</h2>
  • 24. Recommendation: naming classes and IDs for their PURPOSE rather than APPEARANCE
  • 25. Class vs ID
  • 26. Use a class 1. The style is used in various places throughout the document. 2. The style is very general. <span class= &quot; alert &quot;> <span class= &quot; alert error &quot;> <h2 class= &quot; headline &quot;>
  • 27. Use an ID 1. The style is only used once ever in the document. 2. The style is specific to a certain area of the document. <div id= &quot; header &quot;> <body id= &quot; home &quot;> <body id= &quot; home page &quot;>
  • 28. ID and class can be friends <li id= &quot; home &quot; class=&quot; current &quot;>
  • 29. Beautiful HTML = Separate presentation from the content the content the content
  • 31. let’s create a photo gallery
  • 32. turn on the X-ray machine leaves.jpg frame.gif
  • 33. photos User add photos by editing html or uploading via a CMS gallery
  • 34. Photos are content Drop shadows and borders are presentation
  • 35. content is user input data HTML should hold content only HTML should hold content only
  • 36. <ul id= &quot;gallery&quot;> <li> <img src=&quot;leaves.jpg&quot; /> </li> <li> <img src=&quot;balloon.jpg&quot; /> </li> <li> <img src=&quot;sea.jpg&quot; /> </li> <li> <img src=&quot;trees.jpg&quot; /> </li> <ul> HTML
  • 37. #gallery { list-style:none; } #gallery li { float:left; margin-right:20px; background:url(frame.gif) no-repeat; padding: 5px 5px 10px 5px; } #gallery img { display:block; width:150px; height:150px; } CSS
  • 38. STAY readable & organized O O O O O
  • 39. Use <!--comment --> to create separated code blocks to create separated code blocks
  • 40. <!-- header --> <div id=&quot;header&quot;> ... <div> <!-- end of header --> <!-- main --> <div id=&quot;main&quot;> ... <div> <!-- end of main -->
  • 41. use indent to improve hierarchy
  • 42.
  • 43.
  • 44.
  • 45. HTML thật là điệp! Đúng dzồi! Đúng dzồi!