×

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 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.

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.

Internal CSS

What is CSS? CSS stands for Cascading Style Sheet.CSS is used to apply styling the HTML elements.With CSS user can add or change color, font-size and font-family. It also helps user...

4 minutes read.

CSS Radio Button

Radio Button A radio button has been defined as an element of HTML. It can support us to take any input from the user. But it is challenging to design a...

4 minutes read.

CSS Font-Size

A Cascading Style Sheet (CSS) is a simple design scripting language intended to simplify the process of making web pages more visually appealing with the kind of high-level formatting. Cascading...

3 minutes read.

CSS Syntax

The CSS syntax contains the selector and the declaration block, which will be clearer with the following example: Selector: A CSS selector specifies the HTML tag we wish to style. A selector can be...

2 minutes read.

CSS Word Wrap

Word Wrap in CSS: The word-wrap property in CSS is referred to break any lengthy word and wrap towards the next or following line. It is employed for preventing overflow...

1 minute read.

CSS translate() Function

Translate() CSS function This function in CSS is a CSS in-built function. It relocates the element in the horizontal direction or in the vertical direction. It can move the items from...

2 minutes read.

CSS Pseudo-class

Pseudo-class The pseudo-class may be depicted as the keyword which can be mixed to any selector that specifies the elected element’s unique state. It can be included to a selector to...

6 minutes read.

CSS Position

CSS Position: The position property in CSS is applied to set the position of the elements. It can be used to position the backside of an element. It is also...

3 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.

How to create blinking text using CSS

The blinking effect is used in HTML and CSS to take the attraction towards a particular word or section. If you need such a blinking effect, we need to take...

2 minutes read.

CSS Superscript and Subscript

Superscript and Subscript To specify the superscript and the subscript text, HTML provides us two tags that are <sup> and <sub>. The superscript content looks in the shorter font and half...

2 minutes read.

CSS Background-clip

CSS Background-clip: The background-clip property describes the background’s painting area. It limits an area where the image or color of the background appears by using any clipping box. Everything will...

2 minutes read.

CSS Display

CSS Display: The CSS Display property is one of an essential property among all other properties of CSS. The display property specifies how the HTML elements should be displayed on...

4 minutes read.

CSS Color

CSS Colors: The CSS color property is used for setting the HTML element’s color. The color of the fonts and the color of the background can be set-up by using...

5 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 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.

CSS @keyframes rule

CSS @keyframes rule It describes the rule of animation that depicts the properties of CSS for the components at every state along with the timeline. We may make the properties of complex...

4 minutes read.

CSS Selector

CSS Selector: There are some selectors used in CSS, which allows us to choose the content we wish to style. Various selectors are considered as the separation of the set...

5 minutes read.