10 html rules you must know

HTML (Hypertext Markup Language) is a standard language used to create web pages. It is a markup language, which means it is used to “mark up” text in order to make it appear a certain way on the web. For you to mark up these text there are some rules which have been put in placed that must be followed.

These rules are are a combination of guidelines and best practices that have been developed over time by the web development community. These rules are based on the World Wide Web Consortium (W3C) standards for HTML, which define the syntax and structure of the language. The W3C is an international organisation that sets standards for the World Wide Web, and its standards are widely used and accepted by the web development community.


Here are 10 rules to keep in mind when writing HTML:

  1. All HTML elements must have an opening and closing tag. For example, <p> is the opening tag for a paragraph, and </p> is the closing tag.
  2. Avoid using uppercase letters in your HTML code. HTML is case-insensitive, also using lowercase letters makes your code easier to read and maintain.
  3. Elements should be nested properly. For example, a <p> element should be placed within a <body> element, and not within a <head> element.
  4. The <!DOCTYPE> declaration should always be the first line of your HTML document, and should specify the version of HTML you are using.
  5. Elements should be closed in the opposite order they were opened. For example, if you open a <div> element, you should close it </div> before closing the parent element.
  6. The <html> element should contain both <head> and <body> elements, and all other elements should be nested within these.
  7. Attribute values should always be enclosed in double or single quotes. For example, <img src="image.jpg"> is correct, but <img src=image.jpg> is not correct.
  8. The <head> element should include a <title> element, which will be displayed in the browser’s title bar or tab.
  9. Use proper indentation to make your HTML code more readable and easy to understand.
  10. Always check your HTML code in multiple browsers to ensure that it works as expected and that it is cross-browser compatible.

It’s important to note that as the web development community evolves and new technologies emerge, the rules and guidelines for HTML may change or be updated over time.