From the course: HTML Essential Training

Terminology and syntax

- Just like learning any spoken or written language, the best way is to start by learning the rules of that language. When it comes to coding, we can think of syntax and terminology as basically the grammar, punctuation, and vocabulary rules for that coding language. HTML stands for Hypertext Markup Language and is used to add structure and meaning to content on webpages. You may have also heard of two variations of this term, XHTML and HTML5. XHTML refers to an older version based on the XML language. HTML5 came after XHTML and is the latest version. Each version is updated with new features to keep up with advancements in tech and the changing needs of users. These days, HTML specifications are updated in parts as needed instead of full numbered releases. This means we're unlikely to see in HTML6, but the language continues to evolve and improve. At the end of the day, it's all HTML. There are many types of HTML elements, which are used to mark up the content on a webpage. These elements not only control appearance, but also communicate the content's meaning to the browser, a concept known as semantics. Think about any word processing app or any type of writing tool you've used. The interface usually provides options to format text into headings, subheadings, paragraphs, and lists. You're also able to bold or italicize text. Some other options include embedding media such as images, adding links, and more. When writing HTML, instead of selecting an icon or button, we create these different types of elements using HTML tags. Tags are written by enclosing the element name within left and right angle brackets. The opening tag marks the beginning of the element. The closing tag marks the end of an element and must include a forward slash directly before the tag name. The content to be displayed in the browser is added between the opening and closing tag. The complete structure is the HTML element. Different elements are used for various types of content and each has its own specific tag name. Some are text-based, such as headings and paragraphs, which are defined using an h1 and p tag. Other elements like header and section are used to create page structure. HTML tags can also be written inside of other HTML tags. Most HTML tags are written in pairs, but there are some exceptions. These are called void elements, also referred to as self-closing. They do not require a closing tag. Instead of wrapping content, they are the content themselves, like the hr tag, which adds a divider line. Or they're used to embed web resources like image tags used for images. You may see the old XHTML syntax still being used today, which includes a forward slash after the tag name. While both formats work in the browser, it's best to use the current syntax. HTML tags are not case sensitive. They can be written in uppercase or lowercase letters, but for consistency and to improve readability, it's best practice to use lowercase letters. Attributes are used to add additional information or functionality to an HTML element. They're included in the opening tag after the tag name and separated by a space. They can be defined with or without a value. When used without values, they're called Boolean attributes. Multiple attributes can be added to an element in any order, but must be separated by a space. There are many types of attributes which will be discussed in more details throughout this course. Whether you are working on your own or with the team, there are times you may want to add notes to your code. You can do that with HTML comments. They can only be seen in the source code and will not be displayed in the browser. Comments are often used to hide code for later use, document your work, provide explanations, and to organize the code. To write a comment, start with left angle bracket followed by an exclamation mark and two dashes. To close the comment, use two dashes followed by a right angle bracket. Any type of characters or line breaks can be included in a comment as long as they remain between the opening and closing brackets. Understanding the fundamental HTML terminology and syntax rules will help you write clean, well-structured code.

Contents