Open In App

Difference Between HTML and SGML

Last Updated : 22 Nov, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Most of us are familiar with HTML due to its connection to the World Wide Web. It drives the internet, allowing us to build and use websites, share material, and communicate with online services. HTML is only one branch of a much broader tree called SGML, which serves as the basis for several markup languages used in fields outside of the web. In this 

HTML

HTML is the common language used to describe how web pages are presented and structured. HTML pages are made up of several elements, or tags, that represent various content components, including headers, paragraphs, lists, links, and more. Text, photos, multimedia, and other web-related resources are formatted and arranged using these components. Additionally, HTML documents frequently start with a <!DOCTYPE> declaration that identifies the HTML version and document type.

Features

  • Hypertext Markup Language, or HTML, is a popular markup language for developing and organizing material on the World Wide Web.
  • HTML is compatible & works well on almost all Browsers.
  • Angle brackets (<>) are used to surround each element in HTML, and each element may have attributes that offer further details.

Example: In this HTML example, you can see tags like <html>, <head>, <title>, <body>, <h1>, <p>, <ul>, and <li> are used to structure and format the content.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>HTML VS SGML</title>
</head>
  
<body>
    <h2>Welcome To GFG Page.</h2>
    <p>This is a paragraph.</p>
    <ul>
        <li>GeeksForGeeks</li>
        <li>Learning Portal</li>
    </ul>
</body>
  
</html>


Output:

WhatsApp-Image-2023-10-10-at-194455_cbbab300

 

Advantages

  • Simplicity: HTML is accessible to a wide variety of users, including beginners, and is comparatively simple to learn and use.
  • Standardization: HTML provides clear standards and requirements, providing uniformity in how online documents are rendered by various browsers.
  • Extensibility: To improve the appearance and functionality of web pages, HTML may be expanded using CSS (Cascading Style Sheets) and JavaScript.

Disadvantages

  • Limited Expression: HTML lacks the expressive ability of more broad markup languages like SGML and is primarily designed for the display of web content.
  • Semantic Challenges: It can be difficult to maintain semantic accuracy in HTML because users sometimes mistake tags for presentational rather than semantic meaning.
  • Lack of Rich Metadata: Compared to SGML, HTML has fewer metadata features, which makes it less suited for some applications that require a lot of data.

SGML

For establishing markup languages, SGML(Standard Generalized Markup Language), is a standardized, adaptable, and very expressive language. For several document markup languages, including HTML, it serves as the basis. The rules regulating the structure and semantics of texts can be specified using the SGML framework. It enables the development of markup languages with specific needs in mind.

One of SGML’s most important characteristics is its ability to construct Document Type Definitions (DTDs), which are collections of guidelines that specify the components, their properties, and their connections inside a certain markup language. Document structure and content are formally specified by DTDs. The idea of entities, which may be used to build reusable content fragments like character entities or whole documents, is likewise supported by SGML.

Features of SGML

  • The SGML has an entity system that provides the feature of reusability of the content pieces.
  • It provides the feature for the user to create their own markup language and document formats.

Example: In this example, we will write a code in a structured document represented in an SGML-like format.

HTML




<EMAIL>
    <RECEIVER>
        <PERSON>
            <FIRSTNAME>Alice</FIRSTNAME>
        </PERSON>
    </RECEIVER>
  
    <BODY>
        <p>This is a sample paragraph for demonstrating
            SGML Example. The receiver's first name is
            included in the content.</p>
    </BODY>
</EMAIL>


Output:

Screenshot-(635)

SGML Example Output

Advantages

  • Flexibility: SGML’s ability to be customized to certain document types and sectors enables the development of markup languages.
  • Rich Metadata: SGML has strong metadata features, making it appropriate for applications involving structured data and document management.
  • Reusability: The entity system in SGML makes it possible to reuse content pieces, which enhances document consistency and maintenance.

Disadvantages

  • Complexity: SGML requires a deeper comprehension of markup language concepts than HTML and is more challenging to master.
  • Lack of Widespread Browser Support: SGML’s utility in web development is constrained since, unlike HTML, it is not natively supported by web browsers.
  • Implementation Overhead: Creating and maintaining SGML DTDs can take a lot of effort and resources.

Difference Between HTML vs SGML 

Aspect

HTML (Hypertext Markup Language)

SGML (Standard Generalized Markup Language)

Definition A subset of SGML called HTML was created expressly for the creation of documents and web pages. A more general markup language called SGML is used to specify document structure and content across many different industries.
Purpose Designed to organize and display material on the Internet. Created and managed for markup languages used in a variety of applications and businesses.
Complexity It is less complicated than SGML since it has been streamlined and tailored for online content. Because it offers a foundation for building unique markup languages, it is more complicated and adaptable.
Tag Names The tags used in HTML (such as ‘<p>’, ‘<a>’, and ‘<div>’) have predetermined meanings. According to the needs of the document, users can specify their tags and attributes using SGML.
Strictness Since HTML has stronger syntax and error handling, well-formed documents are frequently needed. SGML offers greater flexibility and, depending on the requirements of the application, may not strictly enforce standards.
Standardization There are several HTML versions with established requirements (for example, HTML4, HTML5). Applications of SGML (like DocBook and DITA) are often defined independently from SGML itself because it is a standard.
Usage Primarily used for web content and web applications Widely used, notably in the publishing, aerospace, and technical documentation sectors.
Document Declaration HTML documents typically start with ‘<!DOCTYPE HTML>’ or similar declarations. The structure and restrictions of an SGML document must be specified in a Document Type Definition (DTD) declaration.
Browser Rendering HTML is built with an emphasis on visual appearance for web browser rendering. The primary goals of SGML are document structure and data semantics, rather than immediate display.
Extensibility In the HTML standards, there is little room for expansion. A revised standard must be created to include new components. It is very extensible, enabling users to create their own markup languages and document formats.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads