Home βͺ HTML Tutorials βͺ 7 More HTML Tips and Tricks You Should Know
7 More HTML Tips and Tricks You Should Know !
Use HTML comments to explain sections of your code or leave reminders without affecting the page.
Example:
<!DOCTYPE html>
<html>
<body>
<!-- This is a comment. It won't show in the browser -->
<p>This paragraph is visible.</p>
</body>
</html>
output π
This paragraph is visible.
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Explanation: Comments are useful for code documentation or disabling parts of code without deleting them.
Use the target="_blank" attribute in <a> tags to open links in a new browser tab.
Example:
<!DOCTYPE html>
<html>
<body>
<a href="https://tut.shinecap.co.in/post/html-tutorials/html-colors-complete-guide-color-codes-html.html" target="_blank">Visit HTML Colors:</a>
</body>
</html>
output π
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Explanation: This keeps your site open while visitors explore external resourcesβgreat for reducing bounce rate.
Let users email you directly by clicking a link with a mailto: in the href.
Example:
Example π
<a href="mailto:support@Example:.com">Email Us</a>
Explanation: This opens the user's email app with your address pre-filled.
Disable inputs or buttons to prevent user interaction.
Example:
<!DOCTYPE html>
<html>
<body>
<input type="text" value="Not editable" disabled>
<button disabled>Submit</button>
</body>
</html>
output π
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Explanation: Useful for fields that shouldn't be edited or buttons that are temporarily inactive.
Hovering over an element with a title attribute shows a small tooltip.
Example:
<!DOCTYPE html>
<html>
<body>
<p title="Extra info">Hover over this text</p>
</body>
</html>
output π
Hover over this text
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Explanation: Provides helpful hints or additional info without cluttering your page.
Prevent form submission unless a field is filled.
Example:
<!DOCTYPE html>
<html>
<body>
<form>
<input type="text" required placeholder="Enter your name">
<button type="submit">Submit</button>
</form>
</body>
</html>
output π
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Explanation: Makes sure users don't skip important fields, improving form accuracy.
Some characters (like <, >, &) must be written as HTML entities to display properly.
Example:
<!DOCTYPE html>
<html>
<body>
<p><div> is a block element.</p>
<p>Use & to write an ampersand.</p>
</body>
</html>
output π
<div> is a block element.
Use & to write an ampersand.
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Explanation: Helps display reserved characters in content safely.
These extra HTML tips give you even more tools to improve your coding. Whether you're building a small page or a big website, these tricks help you write better, faster, and smarter code. Keep exploring, keep learning, and always look for ways to make your HTML cleaner and more effective.