HTML Tags Vs Elements - Tutorial Republic (2024)

In this tutorial you will learn about HTML tags and elements.

HTML Element Syntax

An HTML element is an individual component of an HTML document. It represents semantics, or meaning. For example, the title element represents the title of the document.

Most HTML elements are written with a start tag (or opening tag) and an end tag (or closing tag), with content in between. Elements can also contain attributes that define its additional properties. For example, a paragraph, which is represented by the p element, would be written as:

HTML Tags Vs Elements - Tutorial Republic (1)

We will learn about the HTML attributes in the next chapter.

Note: All elements don't require the end tag or closing tag to be present. These are referred as empty elements, self-closing elements or void elements.

HTML Tags Vs Elements

Technically, an HTML element is the collection of start tag, its attributes, an end tag and everything in between. On the other hand an HTML tag (either opening or closing) is used to mark the start or end of an element, as you can see in the above illustration.

However, in common usage the terms HTML element and HTML tag are interchangeable i.e. a tag is an element is a tag. For simplicity's sake of this website, the terms "tag" and "element" are used to mean the same thing — as it will define something on your web page.

Case Insensitivity in HTML Tags and Attributes

In HTML, tag and attribute names are not case-sensitive (but most attribute values are case-sensitive). It means the tag <P>, and the tag <p> defines the same thing in HTML which is a paragraph.

But in XHTML they are case-sensitive and the tag <P> is different from the tag <p>.

<p>This is a paragraph.</p><P>This is also a valid paragraph.</P>

Tip: We recommend using lowercase for tag and attributing names in HTML, since by doing this you can make your document more compliant for future upgrades.

Empty HTML Elements

Empty elements (also called self-closing or void elements) are not container tags — that means, you can not write <hr>some content</hr> or <br>some content</br>.

A typical example of an empty element, is the <br> element, which represents a line break. Some other common empty elements are <img>, <input>, <link>, <meta>, <hr>, etc.

Example

Try this code »

<p>This paragraph contains <br> a line break.</p><img src="images/sky.jpg" alt="Cloudy Sky"><input type="text" name="username">

Note: In HTML, a self-closing element is written simply as <br>. In XHTML, a self-closing element requires a space and a trailing slash, such as <br />.

Nesting HTML Elements

Most HTML elements can contain any number of further elements (except empty elements), which are, in turn, made up of tags, attributes, and content or other elements.

The following example shows some elements nested inside the <p> element.

Example

Try this code »

<p>Here is some <b>bold</b> text.</p><p>Here is some <em>emphasized</em> text.</p><p>Here is some <mark>highlighted</mark> text.</p>

Tip: Placing one element inside another is called nesting. A nested element, also called a child element, can be a parent element too if other elements are nested within it.

HTML tags should be nested in correct order. They must be closed in the inverse order of how they are defined, that means the last tag opened must be closed first.

Example

Try this code »

<p><strong>These tags are nested properly.</strong></p><p><strong>These tags are not nested properly.</p></strong>

Writing Comments in HTML

Comments are usually added with the purpose of making the source code easier to understand. It may help other developer (or you in the future when you edit the source code) to understand what you were trying to do with the HTML. Comments are not displayed in the browser.

An HTML comment begins with <!--, and ends with -->, as shown in the example below:

Example

Try this code »

<!-- This is an HTML comment --><!-- This is a multi-line HTML comment that spans across more than one line --><p>This is a normal piece of text.</p>

You can also comment out part of your HTML code for debugging purpose, as shown here:

Example

Try this code »

<!-- Hiding this image for testing<img src="images/smiley.png" alt="Smiley">-->

HTML Elements Types

Elements can be placed in two distinct groups: block level and inline level elements. The former make up the document's structure, while the latter dress up the contents of a block.

Also, a block element occupies 100% of the available width and it is rendered with a line break before and after. Whereas, an inline element will take up only as much space as it needs.

The most commonly used block-level elements are <div>, <p>, <h1> through <h6>, <form>, <ol>, <ul>, <li>, and so on. Whereas, the commonly used inline-level elements are <img>, <a>, <span>, <strong>, <b>, <em>, <i>, <code>, <input>, <button>, etc.

You will learn about these elements in detail in upcoming chapters.

Note: The block-level elements should not be placed within inline-level elements. For example, the <p> element should not be placed inside the <b> element.

Previous Page Next Page

HTML Tags Vs Elements - Tutorial Republic (2024)

References

Top Articles
'Millions of people have bought a lie' over Manchester Arena attack, ex-TV producer tells court
Kamala Harris gaining voters. | Florida Outdoor Forums
Umbc Baseball Camp
Katie Pavlich Bikini Photos
My E Chart Elliot
Trevor Goodwin Obituary St Cloud
Booknet.com Contract Marriage 2
Immobiliare di Felice| Appartamento | Appartamento in vendita Porto San
Cad Calls Meriden Ct
2024 Fantasy Baseball: Week 10 trade values chart and rest-of-season rankings for H2H and Rotisserie leagues
Craigslist Furniture Bedroom Set
Richard Sambade Obituary
Www Craigslist Louisville
Noaa Swell Forecast
Flat Twist Near Me
Knaben Pirate Download
Explore Top Free Tattoo Fonts: Style Your Ink Perfectly! 🖌️
OSRS Dryness Calculator - GEGCalculators
Hartland Liquidation Oconomowoc
Weather Rotterdam - Detailed bulletin - Free 15-day Marine forecasts - METEO CONSULT MARINE
Bing Chilling Words Romanized
Jang Urdu Today
Aris Rachevsky Harvard
Craigslist Clinton Ar
Troy Gamefarm Prices
eugene bicycles - craigslist
4 Times Rihanna Showed Solidarity for Social Movements Around the World
Marilyn Seipt Obituary
Firefly Festival Logan Iowa
Penn State Service Management
Gt7 Roadster Shop Rampage Engine Swap
WOODSTOCK CELEBRATES 50 YEARS WITH COMPREHENSIVE 38-CD DELUXE BOXED SET | Rhino
417-990-0201
Salons Open Near Me Today
Los Amigos Taquería Kalona Menu
Ixlggusd
Audi Q3 | 2023 - 2024 | De Waal Autogroep
House Of Budz Michigan
Games R Us Dallas
450 Miles Away From Me
My.lifeway.come/Redeem
Housing Intranet Unt
More News, Rumors and Opinions Tuesday PM 7-9-2024 — Dinar Recaps
COVID-19/Coronavirus Assistance Programs | FindHelp.org
Searsport Maine Tide Chart
Walmart Listings Near Me
Kushfly Promo Code
Craiglist.nj
Joe Bartosik Ms
Compete My Workforce
Lake County Fl Trash Pickup Schedule
Latest Posts
Article information

Author: Kimberely Baumbach CPA

Last Updated:

Views: 6227

Rating: 4 / 5 (61 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Kimberely Baumbach CPA

Birthday: 1996-01-14

Address: 8381 Boyce Course, Imeldachester, ND 74681

Phone: +3571286597580

Job: Product Banking Analyst

Hobby: Cosplaying, Inline skating, Amateur radio, Baton twirling, Mountaineering, Flying, Archery

Introduction: My name is Kimberely Baumbach CPA, I am a gorgeous, bright, charming, encouraging, zealous, lively, good person who loves writing and wants to share my knowledge and understanding with you.