DEV Community

IFTIKHAR QURESHI
IFTIKHAR QURESHI

Posted on • Updated on

Top 5 HTML Tricks and Tips

5 Useful HTML Tricks and Tips

  1. Always close your HTML tags When you type an opening HTML tag (e.g., b>, p>), always follow it with the corresponding closing tag. As an example:

5 Useful HTML Tricks and Tips

5 Useful HTML Tricks and Tips

5 Useful HTML Tricks and Tips

This ensures that your HTML pages work properly in all browsers and helps to prevent strange problems from occurring in your pages! This is especially true for tags like div>, span>, table>, tr>, and td>.

  1. When possible, style HTML with style sheets.
    Style sheets will greatly simplify your HTML coding. There will be no more font> tags everywhere! You also have much more control over the appearance of your pages, and you can change their appearance simply by editing one style sheet file.

  2. Use an HTML validator
    Before publishing your Web pages, it’s a good idea to run them through an HTML validator. These programmes will detect potential issues such as missing closing tags on tables and the use of tags that will not work correctly in all browsers. Remember that just because your page looks great in the browser you’re using doesn’t mean it will work in others!

HTML validators are also a good way to learn how to use HTML tags correctly – you can learn from your mistakes!

  1. Use HTML comments wisely You can add comments to your HTML code to make it clearer to you (and others). These are code snippets that Web browsers ignore, so they’re useful for adding short notes and reminders within the code:
<div id="nav">
  <ul>
    <li><a href="home.html">Home</a></li>
    <li class="hi"><a href="about.html">About</a></li>
  </ul>
</div>
Enter fullscreen mode Exit fullscreen mode
  1. Use widths and heights with HTML images When using the img> tag, it’s a good idea to specify the width and height of an image. As an example:

<img src="business.jpg" width="234" height="123">

The benefit of doing so is that the Web browser can format the page faster as it loads because it knows how to lay out the images before they are downloaded. This means your visitors can begin browsing your page without having to wait for all of the images to load!

Source: Top 5 HTML Tricks and Tips

Top comments (0)