The Wayback Machine - https://web.archive.org/web/20240814101617/https://www.geeksforgeeks.org/difference-between-html-and-css/
Open In App

Difference between HTML and CSS

Last Updated : 03 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

HTML (HyperText Markup Language) and CSS (Cascading Style Sheets) are the foundational technologies for creating web pages. HTML provides the structure, while CSS defines the style and layout. HTML is used along with CSS and Javascript to design web pages.

HTML (HyperText Markup Language)

HTML is the standard markup language used to create web pages. It structures the content by using elements such as headings, paragraphs, lists, links, images, and more. HTML elements are the building blocks of web pages, allowing developers to embed multimedia, create forms, and design the overall layout.

Features of HTML:

  • Structure: HTML provides the basic structure of a webpage, defining the layout and hierarchy of content using elements such as headings, paragraphs, and lists.
  • Content: HTML is used to add various types of content to a webpage, including text, images, videos, and audio.
  • Links: HTML is used to create links between different pages and websites, allowing users to navigate the web.
  • Forms: HTML is used to create forms that allow users to input data, such as contact information or search queries.

Example: In this example, we will see the basic structure of an HTML document.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
    <title>GeeksforGeeks</title>
</head>
<html>

<body>
    <h1>Welcome to GeeksForGeeks</h1>
</body>

</html>

</html>

Output:

CSS (Cascading Style Sheets)

CSS stands for Cascading Style Sheets and it is used to style web documents. It is used to provide the background color and is also used for styling. It controls the layout, colors, fonts, and overall look of a web page. CSS is also recommended by World Wide Web Consortium (W3C). It can also be used along with HTML and Javascript to design web pages. 

Features of CSS:

  • Style: CSS is used to define the visual style of a webpage, including fonts, colors, backgrounds, and layout.
  • Layout: CSS allows for complex layouts, with the ability to position elements on a page and adjust their size and spacing.
  • Responsiveness: CSS allows for responsive design, where the layout and style of a webpage can adapt to different screen sizes and device types.
  • Animations: CSS can be used to create animations and transitions on a webpage, making it more interactive and engaging.

Example: In this example, we will see the basic structure of an HTML document by using CSS also.

HTML
<html>
<head>
    <style>
        body {
            background-color: red;
        }
    </style>
</head>

<body>
    <h1>Welcome to GeeksForGeeks!</h1>

    <p>This page has red background color</p>
</body>
</html>

Output:

  Similarities between HTML and CSS

  • Syntax: Both HTML and CSS use a similar syntax, with the use of tags and selectors to define elements on a webpage.
  • Separation of Concerns: Both HTML and CSS follow the principle of separation of concerns, where HTML defines the structure and content of a webpage, while CSS defines the style and layout.
  • Cascading: The “C” in CSS stands for “Cascading”, which means that styles can be inherited and overridden based on the order of the style rules and the specificity of the selectors.
  • Integration: HTML and CSS are often used together, with CSS being used to style the elements defined in HTML.

Difference between HTML and CSS

The table below shows the Difference between HTML and CSS:

HTMLCSS
HTML is a markup language used to define a structure of a web page.CSS is a style sheet language used to style the web pages by using different styling features.
It consists of tags inside which text is enclosed.It consists of selectors and declaration blocks.
HTML doesn’t have further types.CSS can be internal or external depending upon the requirement.
We cannot use HTML inside a CSS sheet.We can use CSS inside an HTML document.
HTML is not used for presentation and visualization.CSS is used for presentation and visualization.
HTML has comparatively less backup and support.CSS has comparatively higher backup and support.
HTML doesn’t allow animations and transitions.CSS allows animation and transitions which helps to improve the UI.
HTML files are saved with .htm or .html extension.CSS files are saved with .css extension.

Conclusion:

HTML and CSS are both essential tools for building websites, but they serve different purposes. HTML provides the structure and content of a webpage, while CSS provides its presentation and layout. While they are often used together, it’s important to understand the differences between these two languages to create effective and visually appealing websites. With a strong understanding of HTML and CSS, web designers can create websites that are both functional and visually engaging.



Previous Article
Next Article

Similar Reads

Difference between bootstrap.css and bootstrap-theme.css
Bootstrap is an HTML, CSS and JS front-end-framework used for developing responsive and mobile-first projects on the web. It is the framework that comes up with predefined terms, thus giving you the ability to use these codes instead of having to create the codes from scratch. It is a collection of HTML, CSS and JS code that is designed to help bui
5 min read
Difference between CSS Grid and CSS Flexbox
Grid:CSS Grid Layout, is a two-dimensional grid-based layout system with rows and columns, making it easier to design web pages without having to use floats and positioning. Like tables, grid layout allow us to align elements into columns and rows. To get started you have to define a container element as a grid with display: grid, set the column an
4 min read
What is the difference between &lt;html lang="en'&gt; and &lt;html lang="en-US'&gt; ?
The lang attribute specifies which language is used to write the content of a web page. It is used to set the language for the whole text of the web page. The &lt;html lang="en"&gt; specifies the language of the document as English, while &lt;html lang="en-US"&gt; narrows it down to English as used in the United States. Table of Content The &lt; ht
2 min read
HTML Code to JSON Converter App Using HTML, CSS, and JavaScript
HTML tables are a common way to represent structured data on web pages, but transforming this data into a JSON format can be troublesome. JSON is a lightweight data-interchange format that is easy for humans to read and write and for machines to parse and generate. We will be creating the HTML Code for the JSON Converter tool. The converter is desi
3 min read
Create a CSS Fireflies background using HTML/CSS
In this article, we will see how to create the CSS Fireflies background using HTML &amp; CSS, along with understanding its implementation through the illustration. The CSS fireflies effect can be created by utilizing the CSS animation and we will implement 3 animations to achieve the fireflies effect. To create randomness, we used different animati
7 min read
Differences between HTML &lt;center&gt; Tag and CSS "text-align: center;" Property
If you are designing a simple web page, then not much difference is noticeable, but it is very necessary to understand the basic differences between these two. Since we are only concerned with the text, these elements do not have separate meanings.HTML &lt;center&gt; tag: The &lt;center&gt; tag in HTML is used to set to align of text into the cente
3 min read
What is the difference between display: inline and display: inline-block in CSS?
The display property in CSS is a very useful and commonly used property that contains many values. The display property defines how an HTML element should be displayed on the webpage. The property also specifies the type of box used for an HTML element and how it should be laid out on the page. If we need to display the elements that are laid out a
4 min read
What is the difference between inline-flex and inline-block in CSS?
The display property specifies how an element should be displayed on a webpage. There can be many values, related to this property in CSS. Inline-block and inline-flex are two such properties. Although there are several values that this property can have, to understand the aforementioned, let us first look into three other values: inline, block, an
3 min read
Difference between revert and unset keyword in CSS
Both of them are keywords in CSS. Both of them act similarly in web development but having differed for some properties for some elements. Revert: The revert keyword is an inbuilt keyword in CSS which has been used to revert the cascading style to its parent element. If any similar elements hold the same cascading style, but one child holds the rev
2 min read
Difference Between CSS and Bootstrap
Cascading Style Sheet(CSS): CSS is developed by Hakon Wium, Bert Bos, World Wide Web 17 December 1996. It is a language used to describes how HTML elements are to be displayed on a web page or layout of HTML documents like fonts, color, margin, padding, Height, Width, Background images, etc. CSS stands for Cascading Style Sheet, here Cascading refe
3 min read
Difference between animation and transition in CSS
CSS transitions allow you to change property values smoothly, but they always need to be triggered like hover. Property changes do not take effect immediately. Over a period of time, the property changes take place. For example, if you change the color of an element from white to black, the change occurs instantly. The CSS changes occur at time int
3 min read
Difference between border ridge and groove styles in CSS
The CSS border-style sets the style of an element’s four borders. This property can have from one to four values. With only one value, the value will be applied to all four borders; otherwise, this works as a shorthand property for each of border-top-style, border-right-style, border-bottom-style, and border-left-style, where each border style is a
3 min read
Difference Between css(‘width’) and width() methods In jQuery
In jQuery, we have two ways to change the width of any HTML element. The jQuery css() method and width() method, below both the methods are described properly with the example. jQuery CSS('width') Method: It is a method present in jQuery which is used to get or set the property on the matched element. It is a property used to get or set the width o
3 min read
Explain difference between Bootstrap and Foundation frameworks in CSS
In this article, we will know about the Foundation &amp; Bootstrap frameworks in CSS, and will also understand their implementation through the example along with discussing the major differences between them. Foundation 6: A Foundation is an open-source &amp; responsive front-end framework built by ZURB in September 2011, that makes it easy to des
7 min read
Difference between auto, 0, and no z-index in CSS
When we have to order elements on the z-axis, we use the z-index property. in CSS, the z-index property only works on elements with a position value other than static. In this article, we will learn about the z-index property and its values, auto, number, initial, and inherit. We will also see the difference between all the values. Syntax: z-index:
3 min read
Difference between CSS Custom Properties and Preprocessor Variables
In this article, we will learn the difference between CSS Custom properties and Preprocessor Variables. CSS Custom Properties: CSS custom properties are also referred to as CSS variables or cascading variables. These entities contain specific values that will be reused in the entire document &amp; can be accessed using the var() function (e.g., col
3 min read
What is the difference between overflow: auto and overflow: scroll in CSS ?
In this article, we will understand the difference between the `scroll` &amp; `auto` values for the overflow CSS shorthand property. The Overflow property specifies the preferred behaviors for an element's overflow i.e., when the content of an element is too large to fit within its block formatting context in both directions. In simple words, it co
3 min read
Difference between CSS Variables and Preprocessor
In this article, You will learn the differences between the CSS variables (cascading variables) and CSS preprocessors. They both implement the extra capabilities into CSS in their own different ways. CSS variables and preprocessors are two different things. Both have advantages and disadvantages. The CSS preprocessor is a language that can be used
6 min read
What is the difference between display:inline-flex and display:flex in CSS ?
In this article, we will see the display property &amp; its values, i.e. the inline-flex &amp; flex, in order to specify the display behavior of an element, along with understanding their basic differences &amp; will illustrate them through the examples. Both CSS display: inline-flex and display: flex properties are used to create flexible layouts.
3 min read
What is the difference between 'width: 100%' and 'width: 100vw' in CSS ?
The CSS width Property is used to set the width of the text and images. The width can be assigned to the text and images in the form of pixels(px), percentages (%), centimeters (cm), etc. The width: 100% sets an element's width relative to its containing block, making it responsive within its parent. The width: 100% responds to the container's size
1 min read
Difference Between Descendant and Child Selectors in CSS
The Descendant selector and child selector in CSS are both used to target specific elements within the document structure, but they differ in their level of specificity and targeting. Descendant SelectorIt uses a space to select all descendants of a particular ancestor. In the below example, It selects all matching elements, regardless of their dep
1 min read
Difference between Inline, Internal and External CSS
CSS is used to add styles on web pages that contain HTML elements. There are three methods to add styles on web pages, these are - Inline, Internal, and External. In this article, we will see the differences between Inline, Internal, and External CSS styles. Table of Content Inline CSSInternal CSSExternal CSSInline, Internal and External CSS Use Ca
5 min read
Difference Between CSS and SCSS
CSS is a stylesheet language whereas SCSS is a preprocessor scripting language that is a superset of CSS. This article will cover the detailed differences between CSS and SCSS. CSS:Cascading Style Sheet is a stylesheet language used to define the presentation and layout of a webpage written in HTML or XML. CSS follows a cascading hierarchy, where s
3 min read
Difference between relative , absolute and fixed position in CSS
CSS positioning is a fundamental concept in web design and development. It allows us to control the layout of elements on a webpage. This article will tell you the differences between relative, absolute, and fixed positioning in CSS. 1. Relative PositioningRelative Position: Relative positioning is a CSS technique that allows an element to be adjus
2 min read
Difference between :first-child and :first-of-type selector in CSS
The :first-child and :first-of-type selectors in CSS are used to target specific child elements within a parent. The :first-child selector targets an element if it is the first child of its parent, regardless of type. On the other hand, the :first-of-type selector targets the first occurrence of a specified element type within its parent. Understan
2 min read
Difference between "." and "#" selector in CSS
CSS selectors are used to apply styles to HTML elements. The dot (.) selector targets elements by class, while the hash (#) selector targets elements by id. Classes can be shared by multiple elements, but an ID is unique within a page, ensuring specific element targeting. Table of Content Id selector("#") Class Selector(".") Difference between clas
3 min read
Difference between CSS and CSS3
CSS (Cascading Style Sheets) is a fundamental technology used to style and format web pages. It enhances the visual presentation of web content by providing various properties like color, layout, background, font, and border. CSS allows better content accessibility, flexibility, and control over the presentation characteristics of web pages. CSS3,
3 min read
Difference between em and rem units in CSS
When setting the size of any element in CSS, you have two choices: absolute units and relative units. Absolute units are fixed and do not change based on other elements. They include units like centimeters (cm), millimeters (mm), and pixels (px). Relative units, on the other hand, are flexible and adjust based on the size of other elements. These u
3 min read
Difference between “resetting” and “normalizing” in CSS
CSS (Cascading Style Sheets) is a powerful stylesheet language used to control the presentation of HTML or XML documents, including SVG, MathML, and XHTML. It defines how elements appear across different media, such as screens, paper, and speech. However, developers often face inconsistencies in browser settings, such as default line heights, margi
4 min read
Difference between CSS and JavaScript
CSS and JavaScript are two fundamental technologies used in web development, each serving a unique purpose. While CSS enhances the visual appeal of a webpage, JavaScript adds interactivity and dynamic content. This article will delve into the differences between these two technologies, shedding light on their distinct roles in web development. CSS,
3 min read
three90RightbarBannerImg