SlideShare a Scribd company logo
My name is @mintran Web designer with 6 years of experience Founder of Frexy Studio and IconEden.com Beautiful HTML & CSS lover I am
Writing beautiful HTML HTML by @mintran Frexy.com
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
<div>My headline <br/></br></div> <div>Sub headline</div> <div>A paragraph</div> <h1> My headline  </h1> <h4> Sub headline </h4> <p> A paragraph </p> rather than
Multiple nested-DIVs  are  EVIL EVIL
<div id=&quot;navigation&quot;>  <div class=&quot;active&quot;>  <div class=&quot;buttonLeft&quot;>  <div class=&quot;buttonRight&quot;> <div class=&quot;strong&quot;> <a href=&quot;#&quot;>Home</a> </div>  </div>  </div>  </div>  this is EVIL
BE structural &   hierarchic O O O O O
<div id=&quot;nav&quot;>   <ul>   <li class=&quot;active&quot;><a href=&quot;#&quot;>Home</a></li>   <li><a href=&quot;#&quot;>About Us</a></li>   <li><a href=&quot;#&quot;>Contact Us</a></li>   <li><a href=&quot;#&quot;>Services</a></li>  </ul> </div>
<div id=&quot;nav&quot;>   <ul>   <li class=&quot;active&quot;><a href=&quot;#&quot;>Home</a></li>   <li><a href=&quot;#&quot;>About Us</a></li>   <li><a href=&quot;#&quot;>Contact Us</a></li>   <li><a href=&quot;#&quot;>Services</a></li>  </ul> </div> Use best practices
<ul id=&quot;nav&quot;>   <li class=&quot;active&quot;> <a href=&quot;#&quot;>Home</a> </li>   <li> <a href=&quot;#&quot;>About Us</a> </li>   <li> <a href=&quot;#&quot;>Contact Us</a> </li>   <li> <a href=&quot;#&quot;>Services</a> </li> </ul> Beautiful!
Beautiful HTML =  Use proper tags every type  of  data
<p>  for  paragraph <p> this is a paragraph</p> <p> this is another paragraph</p>
<h1>, <h2>,...<h6>  for  headlines <h1> Site name </h1> <h2> Main Headline </h2> <h3> Normal Headline </h3> <h4> Sub headline </h4>
<ul>   for Unordered list Navigation
<ul>   for Unordered list Navigation <ol>   for Ordered list Step indicators
<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
<div id=&quot;left&quot;> <ul id=&quot;nav&quot;> <li> <ul> <li> ... </li> <li> ... </li> </ul> </li> <li>...</li> </ul> <div>
<div id=&quot;left&quot;> <ul id=&quot;nav&quot;> <li> <ul> <li> ... </li> <li> ... </li> </ul> </li> <li>...</li> </ul> <div> rather than
Conclusion There’s no rule, just recommendations Always use the best methods and best practices  Say goodbye to bad coding habits Build more websites Code validator is your best friend
HTML thật là điệp! Đúng dzồi! Đúng dzồi!

More Related Content

PPT
Web Services
PDF
Practica Html3
PPT
Remembrance wordles
PPTX
Hyper Text Markup Language
PPT
CSS - Externes Stylesheet
PPT
PPT
CSS: Stildeklaration im head-Bereich
PPT
Manual al-aire
Web Services
Practica Html3
Remembrance wordles
Hyper Text Markup Language
CSS - Externes Stylesheet
CSS: Stildeklaration im head-Bereich
Manual al-aire

What's hot (10)

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

Writing beautiful HTML

  • 1. My name is @mintran Web designer with 6 years of experience Founder of Frexy Studio and IconEden.com Beautiful HTML & CSS lover I am
  • 2. Writing beautiful HTML HTML by @mintran Frexy.com
  • 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. <div>My headline <br/></br></div> <div>Sub headline</div> <div>A paragraph</div> <h1> My headline </h1> <h4> Sub headline </h4> <p> A paragraph </p> rather than
  • 9. Multiple nested-DIVs are EVIL EVIL
  • 10. <div id=&quot;navigation&quot;> <div class=&quot;active&quot;> <div class=&quot;buttonLeft&quot;> <div class=&quot;buttonRight&quot;> <div class=&quot;strong&quot;> <a href=&quot;#&quot;>Home</a> </div> </div> </div> </div> this is EVIL
  • 11. BE structural & hierarchic O O O O O
  • 12. <div id=&quot;nav&quot;> <ul> <li class=&quot;active&quot;><a href=&quot;#&quot;>Home</a></li> <li><a href=&quot;#&quot;>About Us</a></li> <li><a href=&quot;#&quot;>Contact Us</a></li> <li><a href=&quot;#&quot;>Services</a></li> </ul> </div>
  • 13. <div id=&quot;nav&quot;> <ul> <li class=&quot;active&quot;><a href=&quot;#&quot;>Home</a></li> <li><a href=&quot;#&quot;>About Us</a></li> <li><a href=&quot;#&quot;>Contact Us</a></li> <li><a href=&quot;#&quot;>Services</a></li> </ul> </div> Use best practices
  • 14. <ul id=&quot;nav&quot;> <li class=&quot;active&quot;> <a href=&quot;#&quot;>Home</a> </li> <li> <a href=&quot;#&quot;>About Us</a> </li> <li> <a href=&quot;#&quot;>Contact Us</a> </li> <li> <a href=&quot;#&quot;>Services</a> </li> </ul> Beautiful!
  • 15. Beautiful HTML = Use proper tags every type of data
  • 16. <p> for paragraph <p> this is a paragraph</p> <p> this is another paragraph</p>
  • 17. <h1>, <h2>,...<h6> for headlines <h1> Site name </h1> <h2> Main Headline </h2> <h3> Normal Headline </h3> <h4> Sub headline </h4>
  • 18. <ul> for Unordered list Navigation
  • 19. <ul> for Unordered list Navigation <ol> for Ordered list Step indicators
  • 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. <div id=&quot;left&quot;> <ul id=&quot;nav&quot;> <li> <ul> <li> ... </li> <li> ... </li> </ul> </li> <li>...</li> </ul> <div>
  • 43. <div id=&quot;left&quot;> <ul id=&quot;nav&quot;> <li> <ul> <li> ... </li> <li> ... </li> </ul> </li> <li>...</li> </ul> <div> rather than
  • 44. Conclusion There’s no rule, just recommendations Always use the best methods and best practices Say goodbye to bad coding habits Build more websites Code validator is your best friend
  • 45. HTML thật là điệp! Đúng dzồi! Đúng dzồi!