How To Create Layout In HTML5

HTML5 has new attractive tags to create a layout in an easy and simple way. These tags are listed below: 
  • <header>: used to define a header section in HTML doc.
  • <nav>: used to define a navigation bar in HTML doc.
  • <section>: used to define a section in HTML doc.
  • <article>: used to define an independent self contained article in HTML doc.
  • <aside>: used to define a content aside from the content like a sidebar in HTML doc.
  • <footer>: used to define a footer for a document or a section in HTML doc.
  • <details>: used to define additional details in HTML doc.
  • <summary>: used to define a heading for the <details> element in HTML doc.
Now, start creating a layout, step by step.
 
Here, I am using Notepad to write HTML code but if you want to use the HTML editor, it's up to you.

Step 1: Open Notepad and save the file with .html extension (shown in the image below):
 


After clicking on the save button, the file is saved as an HTML document 
 
Step 2: Open HTML (index) file,
 
After opening the file, we write our HTML code here.
 
Html code
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4.     <title>my layout</title>  
  5.     <link rel="stylesheet" type="text/css" href="my.css">  
  6. </head>  
  7. <body>  
  8. <header id="header">  
  9. <h1>c# corner</h1>  
  10. </header>  
  11. <nav id="nav">  
  12.     <ul>  
  13.         <li><a href="#">Home</a></li>  
  14.         <li><a href="#">About</a></li>  
  15.         <li><a href="#">Article</a></li>  
  16.         <li><a href="#">Contact</a></li>  
  17.     </ul>  
  18. </nav>  
  19. <aside id="side">  
  20.     <h1>news</h1>  
  21.     <a href="#"><p>creating html website</p></a>  
  22.     <a href="#"><p>learn css</p></a>  
  23.     <a href="#">learn c#</a>  
  24. </aside>  
  25. <article id="article">  
  26.     <h1>Lorem ipsum</h1>  
  27.     <p>Lorem ipsum dolor sit amet, mei cu dolor tamquam impedit. Congue partiendo cu sed, quo eu ipsum offendit. Ad mei nulla patrioque torquatos, adhuc recusabo eum in. Omnium scriptorem ad nec, vidit iracundia vim in.  
  28.   </p>  
  29.   <p>  
  30. Stet epicuri an eum, tempor utroque fierent mei ei. Mei veri indoctum splendide id, eum eu scaevola efficiendi neglegentur. Per no aliquando instructior. Has tempor admodum quaerendum ei.  
  31.   </p>  
  32.   <p>  
  33. No latine detraxit praesent duo, porro soleat copiosae ne cum. Labitur nostrud et pro, mel ut dolor vidisse. Ad liber oporteat qui, te est sumo integre commune, ne sed dico nihil. Ex vel commodo equidem reformidans, sit in elitr repudiandae, ne est tritani suavitate. Ei augue audiam vivendo vim. Vim ut facer instructior, partiendo qualisque ad est. Nam eu autem illud iriure, eleifend praesent expetendis in nam, mutat commune ius ea.  
  34.   </p>  
  35.   <p>  
  36. Ei eos enim exerci persequeris. Ea est veri omnium probatus, scripta sensibus eu ius, no pri semper maluisset cotidieque. Cum mollis phaedrum concludaturque ne, ad aliquid detraxit mel. Ad nam habeo apeirian, an eleifend evertitur intellegam per. At albucius offendit cum.  
  37.   </p>  
  38.   <p>  
  39. Ea usu atqui choro tation. Ei eius salutandi adversarium vis, mentitum accommodare ullamcorper nec ei. Alterum invenire suavitate usu ei, eam invenire efficiantur at. Ex cum tale prodesset, ius ad minim timeam adipiscing. Eu appetere invenire mediocritatem est. His nibh mazim neglegentur ad, qui assum consul qualisque et.  
  40. </p>  
  41. </article>  
  42. <footer id="footer">  
  43.     copyright @c# corner  
  44. </footer>  
  45. </body>  
  46. </html>    
I have provided ID in HTML tags for styling. Open index.htm in the Web Browser.
 
Our Webpage looks as shown in the image below: 


Our Web page is not looking good. In the next step we are going to change our Webpage view, using CSS.
 
Step 3: Open new file in Notepad and save with .css extension (shown in the image, given below):
 


Open my.css file in Notepad and write the code.
 
Css code 
  1. #header{  
  2.     color#247BA0;  
  3.     text-aligncenter;  
  4.     font-size20px;  
  5. }  
  6. #nav{  
  7.     background-color:#FF1654;  
  8.     padding5px;  
  9. }  
  10. ul{  
  11.   
  12.     list-style-typenone;  
  13. }  
  14. li a {  
  15.     color#F1FAEE;  
  16. font-size30px;  
  17. column-width5%;  
  18.     }  
  19.     li  
  20.    {  
  21.     displayinline;  
  22.     padding-left2px;  
  23.     column-width20px;  
  24.    }  
  25.    a{  
  26.  text-decorationnone;  
  27.  margin-left:20px  
  28.     }  
  29.    li a:hover{  
  30.     background-color#F3FFBD;  
  31.     color#FF1654;  
  32.     padding:1%;  
  33.    }  
  34.    #side{  
  35.     text-aligncenter;  
  36.     floatright;  
  37.     width15%;  
  38.     padding-bottom79%;  
  39.     background-color#F1FAEE;  
  40.    }  
  41.    #article{  
  42.     background-color#EEF5DB;  
  43.     padding10px;  
  44.     padding-bottom75%;  
  45.    }  
  46.    #footer{  
  47.     background-color#C7EFCF;  
  48.     text-align:center;  
  49.     padding-bottom5%;  
  50.     font-size20px;  
  51.   
  52.    }  
Save file and run HTML file in web browser
 
Our webpage is looking better(shown in picture),

 
 
Now, learn the attributes in my.css file, shown below:
  1. #header{  
  2.     color#247BA0;  
  3.     text-aligncenter;  
  4.     font-size20px;  
#header is id used in <header> for styling. 
color- is to set text color.
text-aling is used to aline text or show text in center.
font-size to set font size. 
  1. #nav{  
  2.     background-color:#FF1654;  
  3.     padding5px;  
  4. }
#nav is id of <nav>.
Background-color is used to set the background color of our navigation bar.
Padding is used to expand our navigation bar.
  1. ul{  
  2.   
  3.     list-style-typenone;  
  4. }  
Here, we remove dot from the list element, 
  1. li a:hover{  
  2. background-color#F3FFBD;  
  3. color#FF1654;  
  4. padding:1%;  
  5. }  
Hover is used for the navigation bar hover.

Up Next
    Ebook Download
    View all
    Learn
    View all