SwitchUp SwitchUp Ranked Best Coding Bootcamps 2025

HTML Syntax

Written in HTML CSS Development
updated on 10 Jan 2023

HTML stands for HyperText Markup language, it is used to structure the content of a web page and instructs the browser on how to display it. As the name suggests, HTML is not a programming language, it doesn't allow you to do maths and equations. It is merely a language for writing web content for the browser to display.

Just like grammar in spoken languages, each computer language has its own syntax. Syntax is a set of rules that you must follow when you write code; otherwise, the computer cannot understand your instructions.

HTML is made up of elements, each element represents a certain content type. You define an element by using an HTML tag.

Elements are the basic building blocks of HTML, they give meaning to your content as well as help you organize it. Element tags follow a specific syntax. They are written inside angle brackets <elementName>, most elements come in opening and closing tags <html> </html>. Closing tags have a forward slash before the tag name. ('/' forward slash, '\' backward slash)
language=>HTML <elementName attribute="value">element content</elementName>
You can customize your elements by adding attributes in the opening tag, attributes need an attribute name and an attribute value. Common attributes include class and id which we use to easily identify specific content so we can give them special styles.

For example, if we want to assign a class to the following paragraph tag (<p>...</p>), we add class="foo bar" to the opening tag, where "foo bar" is an example for the name of the class:
language=>HTML <p class="foo bar">some paragraph</p>
Make sure you always enclose attribute values in quotation marks. Either double quotation " or single quotation ' is fine, we usually use a double quotation for HTML though. Otherwise, you could end up with misinterpretations like this:
language=>HTML <p class=foo bar>some paragraph</p>
This will be interpreted as the following (not what we intended!):
language=>HTML <p class="foo" bar="">some paragraph</p>
The p element tag stands for a paragraph, the name implies its purpose. It is quite often used in HTML, and it is part of a group of text elements. More on that later.

One more thing to mention is the commenting syntax in HTML. Comments are useful when you are working with others – it helps you add information where the HTML doesn't clearly explain itself. To write a comment, you start with <!-- and end with -->, like this.
language=>HTML <!-- This is a comment --> <!-- This is a multiline comment -->
Comments are not interpreted by the browser so they don't get rendered for the user to see when they are looking at your website.

Trusted by

Students and instructors from world-class organizations

Imperial College London
Carnegie Mellon University
City University of Hong Kong
Hack Reactor
Cisco Meraki
University of Oxford
Swift
Bazaarvoice
Waterloo
Uber
AtlanTech
Tumblr
Boston College
Bombardier Aerospace
University of St. Andrews
New York University
Minerva Schools at KGI
Merrill Lynch
Riot Games
JP Morgan
Morgan Stanley
Advanced Placement®
Google
KPMG
The University of Hong Kong
University of Toronto
SCMP
Moat
Zynga
Hello Toby
Deloitte
Goldman Sachs
Yahoo
HSBC
General Assembly
Tesla
McGill University
Microsoft

Join the upcoming Cohort #103

Enroll for July 7th, 2025