×

Difference between HTML and CSS

HTML

HTML stands for HyperText Markup Language and is used to create web pages and websites and web applications, which means we can create static web pages. Html is a scripting language, and the pages are saved using the .html extension.

Html is used to define the structure of any web page or web application, or website. The basic structure contains a head section, body section, and footer section for any web application.

Html is the basic and first building block while developing any website. The main part of HTML is the tag, so it can also be called a basic unit of the HTML page.

In HTML, several tags are used for several different purposes. These tags provide display information to the browser, meaning each tag has predefined display information, e.g., <a> tag defines a hyperlink that is used to navigate to other web pages. There are different attributes and elements in HTML, and each element has an opening and closing tag.

Advantages: -

  • Html is easy to use, learn and write, and supported by all browsers.
  • It is fast to download because the text is compressible.

Disadvantages: -

  • It can be used only to create a static and plain page.
  • Also, it has limited styling capabilities.

Example:

Code:

<html>
<head>
<title> The title of web page</title>
</head>
<body>
<h1>This is h1 tag</h1>
<p>This is paragraph tag </p>
</body
</html>

Output

Difference Between HTML and CSS

In the above example, with the help of HTML tags, we have created a simple static web page that contains a head, body section, and some tags like heading 1 tag and paragraph tag. The h1 tag makes the heading in bold, and the paragraph tag enters the statements on a new line.

So, this is the basic structure of a web page.Html files can include CSS code and files, but the reverse cannot be done.

Not only that but also HTML is free to use and is not case sensitive, which means tags can be written in upper case as well as in the lower case.

It is also platform-independent because it works on both Linux and Windows, etc.

CSS

CSS is an acronym for Cascading Style Sheet, which is used to style our documents or web pages that are created using HTML. It makes our web application look presentable with its properties, including layout, background color, etc.

CSS is used for controlling the styling of web pages.

The style sheet is saved using the .css extension when creating an external sheet for designing our web pages.

The World Wide Web Consortium(W3C) maintains CSS and is used for multiple styling pages with the same specifications.

We can use CSS inside HTML, but vice versa is not possible.

CSS has selectors and declaration blocks, and there is an id selector (#), a class selector(.), and the universal selector (*).

There are 3 types of CSS:

1)Inline CSS: Styling for particular element/attribute is mentioned inside any tag.

2)Internal CSS: Styling of elements is done inside <style> tag which is inside <head>tag.

3)External CSS: Styling of elements is defined in another file which is of .css extension and is linked in the html file using <link> tag.

Advantages: -

  • It saves a lot of time due to its flexibility and easy maintainability.
  • It can set and update styles for many documents at once.
  • CSS is used for the presentation of web pages.

Disadvantages: -

  • There are different versions of CSS, so that it might become confusing sometime.
  • It works differently on different browsers.

Example: -

style1.css

* {
  background-color: #8fc560;
}
h1 {
  color: blue;
  text-decoration: underline;
  font-family: sans-serif;
}
h2 {
  color: white;
}
h3 {
    color:pink;
}
p {
  font-size: 16px;
  font-family: Comic Sans MS;
}

Html file:

<html>
<head>
<title> </title>
<link rel="stylesheet" href="style1.css">
</head>
<body>
<h1>The web page is css example<h1>
  <h2>This is heading 2</h2>
    <h3>This is heading 3</h3>
<p>This is a paragraph tag </p>
</body>
</html>

Output

Difference Between HTML and CSS

In the above example, an external CSS is created and is linked to the HTML file.

In style1.css, different tags have different properties, like the h1 tag is set with text-decoration, colour, and font family. Not only that, but we can also set margin, padding, so on using CSS.


Related Topics

CSS Tutorial

CSS refers to the Cascading Style Sheet. CSS is a form of a programming language. In other words, CSS is a language of the style sheet that is utilised for...

9 minutes read.

CSS Links

CSS Link is used to create styled link. There are various ways to implement it. Styling Links Link can be styled with CSS properties like color, font-family, background etc. Example: <!DOCTYPE html>   <html>   <head>   <style>   a {       color: red;   }   </style>   </head>   <body>   <p><b><a href="https://www.tutorialandexample.com"    target="_blank">This is a link</a></b></p>   </body>   </html> Try Now There are four...

2 minutes read.

CSS Float

CSS Float: The float property of CSS is the positioning property. This property is applied to elements to push them either to left or right. It permits for wrapping facility...

4 minutes read.

CSS Loader

CSS Loader The loader is the animation that can alert a visitor regarding the loading of the page. We need to wait for some time. It will be helpful if any...

4 minutes read.

CSS Text-Transform Property

Text-Transform in CSS The text-transform property permits us to alter the text case. It controls the capitalization of the text. This property is employed to design the text appearance in every...

3 minutes read.

CSS Comments

CSS Comments: Generally, comments in CSS are used to describe our code. Further, it will provide support to many users who are concerned with the code. Somewhat, these are ignored...

2 minutes read.

CSS 2d Transform

Transform property in CSS is used mainly for enhancing the effects and to animate the elements. Transform is an effect that changes the shape, size and position of an element. It helps...

6 minutes read.

CSS Text-align

Text-align The text-align property of CSS sets the table-cell box’s horizontal alignment or any block element. The text-align property is the same as the CSS property vertical-align but towards any horizontal...

1 minute read.

CSS Justify Content

Justify Content: These properties are applied for the alignment of items of a flexible box container if any item does not cover every available space over the main-axis, i.e., horizontally....

4 minutes read.

CSS Inline

What is CSS? CSS is an acronym for Cascading Style Sheets. CSS is the language that we use to style an HTML document. It specifies how HTML components should appear. CSS...

4 minutes read.

CSS Descendant Selector

Descendant Selector The Descendant selector in CSS is used to match the descendant components of a particular component. The term descendant depicts nested in whatever place, inside a DOM tree. This...

2 minutes read.

CSS Gradient

CSS Gradient: The CSS gradient property is applied to show the smooth transition inside two specified colors or more than two specified colors. Need of CSS Gradient The following are a few...

4 minutes read.

What is a CSS File?

What is a CSS File and How to use it in Html? CSS: - CSS stands for Cascading Style Sheet. CSS is a file of style sheets that describe the presentation of...

4 minutes read.

CSS Pagination

CSS Pagination The pagination in CSS is an advantageous approach for indexing of a website’s distinct pages over the homepage. When our site contains multiple pages, we must insert a few...

13 minutes read.

Cascading Style Sheet

CSS refers to the Cascading Style Sheet. CSS is a form of a programming language. In other words, CSS is a language of the style sheet that is utilised for...

7 minutes read.

What is CSS used for

What is CSS used for? CSS stands for Cascading Style Sheet. CSS is a stylesheet language for web pages. It specifies how a document created in a markup language looks and...

4 minutes read.

How to use google fonts in CSS

Fonts: - Fonts are used to make our website look more beautiful. Choosing appropriate font according to the web design or layout is also important. Many typefaces are accessible in...

4 minutes read.

CSS Counters

CSS Counters: The CSS counter property is similar to the variables. CSS counters are controlled via CSS, and its values are incremented via rules of CSS to record how much...

4 minutes read.

CSS Page-break-before Attribute

Page-break-before Attribute As its name implies, the page-break-before property is applied to include page break before any element, at the time of printing any document. It adds the page break before...

5 minutes read.

CSS Width

CSS Width The width property in CSS sets the content width of area of the element. These properties do not provide margin and border features. It is used to set the...

1 minute read.