Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Saturday, August 29, 2015

Best Practices of HTML5

This post is specifically for those who are just diving into web design industry. If you've one year of experience or less, hopefully some of the tips listed here will help you to become better, quicker!

Learning HTML is not a big task but coding it in proper manner makes you a perfect front end developer. These are the do's and dont's in the HTML page.


html5-best practices

1.) Use the Proper Document Structure

Without a doctype and the structural HTML elements, pages will not render properly in every browser.So user must always be sure to the use proper document structure, including the <!DOCTYPE html> doctype, and the <html>, <head>, and <body> elements. Doing so keeps our pages standards compliant and fully semantic, and helps guarantee they will be rendered as it is. Always use correct doctype declaration.

<!Doctype HTML>
<html>
<head>
 <title> Introduction to HTML</title>
</head>
<body>
<h1>Hello World!</h1>
<p> Introduction to HTML</p>
<span> Learn Semantic </span>
</body>
</html>

2.) Make Use of Semantic Elements

If a HTML document doesn't uses proper semantic structure, then it is meaningless. The HTML element which is opened first should be closed first. Dis-proper closing of HTML tags may not render correctly in browsers.

<p class="heading">Hi Guys! <span>We are back. </p></span>

<p class="heading">Hi Guys! <span>We are back.</span></p>


3.) Close tags where ever necessary

Leaving the tag element unclosed is the common mistake done by all developers. In some advance browsers, it may close tag automatically, but not in all. But there are some standalone tags which doesn't need closing tags and no need to care about that.


<ul>
<li><a href="index.html">Home </li>
<li><a href="about.html">About </li>
</ul>

<ul>
<li><a href="index.html">Home </a></li>
<li><a href="about.html">About </a></li>

</ul>


4.) Use Meta tags without fail

Meta elements are typically used to specify page description, keywords, author of the document, last modified, and other metadata and makes your web page more meaningful for user agents like search engine spiders. So do not omit as others do!


<head>
 <meta name="description" content="web design blog">  

<meta name="keywords" content="web design,.... ">
</head>


<head>
 <meta name="description" content="This blog helps you in learning the basic concepts of web design for beginner level developers">  

<meta name="keywords" content="web design, ui design, ui ux design, designer blog">
</head>


5.) Provide style sheet link and script files in head tag

Placing link to style sheet files and js files can be given inside the head tag using <link> tag. 



<head>  
    <title>My Title</title> 
    <link rel="stylesheet" type="text/css" href="style1.css" /> 
    <link rel="stylesheet" type="text/css" href="style2.css" />  
    <script src="newscript.js" type="text/javascript"></script>
 </head>


6.) Use Alt attribute for <img> tag

Provide text alternatives for any images added through <img> tag. This keyword helps the search engine in finding your site.



<img src="files/image1.jpg" />

<img src="files/image1.jpg" alt="image" />


7.) Start Using HTML5 new Elements


Instead of staying with divs for everything, take some time to learn the new HTML 5 elements like <header>, <footer>, <article> and others. They work the same way but improve readability with less writing.

<html>
<head>
 <title> Learn Semantic HTML </title>
</head>
<body>
<div>
   <h1>Logo Here</h1>
</div>
<div class="nav"> ... </div>
<div>
 <div> side bar </div>
  <div>
 <article> first article </article>
        <article> second article </article>
       <article> third article </article>
  </div>
<div class="copyrights">
   Copyrights Info
</div>
</div>
</body>
</html>

<html>
<head>
 <title> Learn Semantic HTML</title>
</head>
<body>
<header>
   <h1>Logo Here</h1>
</header>
<nav> ... </nav>
<div>
 <aside> side bar </aside>
  <section>
 <article> first article </article>
        <article> second article </article>
       <article> third article </article>
  </section>
<footer>
   Copyrights Info
</footer>
</div>
</body>
</html>


8.) Use Selectors appropriately

Classes can be used multiple times in the documents. They are reusable. But id's are unique. One id can be used only once in a page.

<div id="content">
<p id="loginname"> Vimal Raj </p>
<p id="loginname"> 29th Aug, 2015 </p>
</div>

<div id="content">
<p class="loginname"> Vimal Raj </p>
<p class="loginname"> 29th Aug, 2015 </p>
</div>


9.) Use Title attributes in anchor

Use of title attribute in anchor tags helps the user to understand the need of that link and also it helps in SEO operations.



<a href="../profile.pdf"> Click here</p>

<a href="../profile.pdf" link="profile-info"> Click here</p>


9.) Simplify form elements

Enclose all label names with the <label> tag. Try using the new email and url input types to define these common fields. Using placeholder attribute to provide input hints. Use the required attribute to request validation. Drop the name attribute in favor of an id where needed. Differentiate submit and cancel buttons for easier view.


<form>

<label> Username </label>
<input type="text" name="username" placeholder="Type Username"/>

<label> Email</label>
<input type="email" name="email" placeholder="Type Your Email"/>

<input type="submit" name="sub_form" value="Login"/>

<input type="reset" name="can_form" value="Cancel"/>

</form>


10.) Provide necessary fallback

Provide proper fallback in the HTML. Use browser supportive (IE 8/9) or specific scripts whenever HTML5 components are used in the document. Also provide proper information for non supportive browsers.



<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]--> 

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>


11.) Use External Stylesheet 

As said earlier, always use external stylesheet inside head tag. Avoid using inline style which makes the code clumsy. 


<head>
    ...
    <link rel="stylesheet" type="text/css" href="style.css" />
     ...
 </head>

<p style="color:#365233" font-size:16px;> Login </p>



13.) Validate your HTML 

Finally, dont forget to validate your html file. A semantic html should be pass all the guidelines said in the W3C HTML validator.

Tuesday, August 25, 2015

HTML 5 - A Quick Reference

Get a Quick Reference of HTML5

1.) Are you new to Web design?
2.) Are you a beginner to HTML5? 
3.) Are you willing to create new webpage on your own?

If your answer is YES, then this article is surely going to help you a lot. Today, with this blog post, we are going to talk about HTML5 for beginners, where we will define what HTML is and how it evolved from HTML to HTML5, why you should learn it, what you require for learning HTML5, and much more.

Let us begin now.

What is HTML5?

HTML is an abbreviated form of Hypertext Markup Language, which is used to build web pages that, informs a web browser to visually represent its elements, such as text and images with a set of codes and symbols. Moreover, HTML is the W3C (World Wide Web) recommended standard for creating websites. Tim Berners-Lee, the founder of HTML, introduced the HTML to the world in 1990.


Since 1990 HTML have go through a lot of modifications and improvements based on the suggestions from a wide group of web designers and developers to overcome the difficulties they face while making interactive websites. After the initial recommendation of HTML, it came in new versions such as HTML 2.0 in 1995, HTML 3.2 in 1997, HTML 4.0 in 1997, and HTML 4.01 in 1999, which is then followed by the latest HTML5.

Why to learn HTML?

Many people asks that why we need to learn HTML, when there are pre-designed templates are readily available such as wordpress,etc. It is good question. Not all the readily available website templates are bug free. If you need to customise or edit or alter the webpage, you need to know HTML and CSS. If you learn how HTML works and how to code in HTML, and once you are skilled in HTML, you can easily view the source code and make the customization correctly. But remember only if you are well skilled in HTML.



What is needed for learning HTML?

1.) HTML Editor- Notepad, Notepad++, Adobe Dreamweaver,etc..
2.) Browser - Chrome, Firefox, Internet Explorer, etc..
3.) Little bit of interest in learning and patience.

HTML5 :

There are 2 things to need to know before start learning HTML5.
       a.) The basic HTML5 tags and elements.
       b.) The structure of an HTML5 webpage.
       c.) Cascading Style sheet (CSS).


Basic HTML5 Tags:

As HTML is a markup language it consists of various tags and elements. Tags are generally used in pairs, namely; an opening tag and a closing tag. An opening tag signifies that the browser should render the content placed after it by using all of its given properties, and a closing tag informs the browser about the end of that particular tag.

For example, the opening <html> tag defines the starting point of an HTML page, and its closing </html> tag defines that the HTML content ends here. These tags help browsers to understand what to display, when to display, and what not to display.


Apart from the above mentioned two tags, there are some tags which we call as the self closing tags. Additionally there are some empty HTML elements, which are used without content. For example; the <br> tag is used for single line break, and no content is placed for this tag. Above HTML tags are called as stand alone tags.

These are the commonly used and newly introduced HTML5 tags. 

TAGS
HTML5 NEW ELEMENTS
<!DOCTYPE HTML>
<HEADER>
<HTML>
<HGROUP>
<HEAD>
<NAV>
<TITLE>
<ASIDE>
<BODY>
<FIGURE>
<DIV>
<SECTION>
<P>
<ARTICLE>
<SPAN>
<FOOTER>
<H1>
<AUDIO>
<IMG>
<VIDEO>
<UL>

<OL>

<LI>

<TABLE>

<TR>

<TD>

<IMG>

<BR>

<HR>

<FORM>

<INPUT>

<SELECT>

<OPTION>

<TEXTAREA>

<!-- -->


Basic Structure of HTML:

<HTML>
<HEAD>
<TITLE> Introduction to HTML</TITLE>
</HEAD>
<BODY>
<H1>HELLO WORLD!</H1>
<P> Introduction to HTML</P>
</BODY>
</HTML>

Output:



 HELLO WORLD!

 Introduction to HTML



Basic Structure of HTML5:


<HTML>
<HEAD>
<TITLE> Introduction to HTML5</TITLE>
</HEAD>
<BODY>
<HEADER>
   <H1>LOGO</H1>
</HEADER>
<DIV>
 <ASIDE> SIDE BAR </ASIDE>
  <SECTION>
<ARTICLE> MAIN CONTENT</ARTICLE>
        <ARTICLE> MAIN CONTENT</ARTICLE>
       <ARTICLE> MAIN CONTENT</ARTICLE>
  </SECTION>
<FOOTER>
   COPYRIGHTS INFO
</FOOTER>
</DIV>
</BODY>
</HTML>

Output:


HTML5 basic structure

These are the basic things to learn in HTML5. There are more elements to be learnt in HTML5 and those topics will be discussed in later posts.

Source: instructables