HTML Elements

HTML Elements An HTML element is everything from the start tag to the end tag: Start tag Element content End tag <p> This is...

HTML Elements

An HTML element is everything from the start tag to the end tag:

Start tag Element content End tag
<p> This is a paragraph </p>
<a href="default.htm" > This is a link </a>


HTML Element Syntax

  • An HTML element starts with a start tag
  • An HTML element ends with an end tag
  • The element content is everything between the start and end tag
  • Some HTML elements have empty content
  • Some HTML elements have a missing end tag
Note: The start tag can have additional information (attributes). See next chapter.

Nested HTML Elements

Most HTML elements can be nested (can contain other HTML elements).
Most HTML documents consist of nested HTML elements.

HTML Document Example

<html>
<body>
<p>This is my first paragraph</p>
</body>
</html>
The example above contains 3 HTML elements:

<p>This is my first paragraph</p>

The <p> element defines a paragraph in the HTML document:
The element has a start tag <p> and an end tag </p>
The element content is: This is my first paragraph

<body>
<p>This is my first paragraph</p>
</body>

The <body> element defines the body of the HTML document
The element has a start tag <body> and an end tag </body>
The element content is another element (a paragraph)

<html>
<body>
<p>This is my first paragraph</p>
</body>
</html>

The <html> element defines the whole HTML document.
The element has a start tag <html> and an end tag </html>
The element content is another element (the body)

Empty HTML Elements

HTML elements without content are called empty elements. Empty elements have no end tag.
<br /> is an empty element without a closing tag.
In XHTML, XML, and future versions of HTML, all elements must be closed.
Adding a slash to the start tag, like <br />, is the proper way of closing empty elements, accepted by HTML, XHTML and XML.
Even if <br> works in all browsers, writing <br /> instead is more future proof.

HTML Tip - Lowercase Tags

HTML tags are not case sensitive: <P> means the same as <p>. Plenty of web sites use uppercase HTML tags in their pages.
1000sourcecodes use lowercase tags because the World Wide Web Consortium (W3C) recommends lowercase in HTML 4, and demands lowercase tags in newer versions of (X)HTML.
Name

ADO,131,ASP,3,C++,61,CORE JAVA,1,CSS,115,HTML,297,index,5,JAVASCRIPT,210,OS,47,PHP,65,SAD,53,SERVLETS,23,SOFTWARE ENGINEERING,245,SQL,71,TCP/IP,1,XHTML,9,XML,18,
ltr
item
Best Online Tutorials | Source codes | Programming Languages: HTML Elements
HTML Elements
Best Online Tutorials | Source codes | Programming Languages
https://www.1000sourcecodes.com/2012/05/html-elements.html
https://www.1000sourcecodes.com/
https://www.1000sourcecodes.com/
https://www.1000sourcecodes.com/2012/05/html-elements.html
true
357226456970214079
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content