Last Updated On By Anmol Lohana
HTML is used for Hypertext Markup Language, and CSS is used for Cascading Style Sheets. HTML vs CSS: These two are the core web scripting languages to build web pages and web applications. HTML gives structure to the web pages, whereas CSS gives styling and layout to the web pages.
Table of Contents
In HTML, there are some tags to define the content of a web page. For different content, there are different tags available in HTML. The main tag is an HTML tag; inside the HTML tag, two tags use head and body tags. Inside of head tag, you can add the content of your web page header content like title, links, etc., and inside the body tag, you can add the content of your web page.
If you want to add a heading to your web page, there are six heading tags in HTML from h1 to h6. It depends on which heading you want to add according to the size requirements. Likewise, there are different tags to add different things to your web pages. You can add tags like opening tag, and closing tag.
For example, if you want to add heading number three, and page title as Heading Example, you can add like.
<html>
<head>
<title>Heading Example</title>
</head>
<body>
<h3> Your Heading Here </h3>
</body>
</html>
In CSS, you can give styling to your web page content. It does not support tags in CSS; you need to add properties to the HTML tags or selectors. As you added a heading on your web page, it will show you a simple heading, but you can make it representable by giving it the color, size, background color, background image and more properties.
You can provide styling by using HTML tags name, properties inside curly braces, each property separated by a comma.
For example, if want to give color, size, and background color to your heading you can give like.
h3 {
size: 50px,
color: blue,
background-color: aqua
}
Let’s execute the example and see the results. To run this, you only need to open the .html file in any browser, and it will show you the results.
First we will execute the html code only and then CSS.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Heading Example</title>
</head>
<body>
<h3>Your Heading Here</h3>
</body>
</html>
h3 {
color: blue;
background-color: aqua;
size: 50px;
}
It will show you the same result. These properties will be applied when you link the CSS file with html. Like:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Heading Example</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h3>Your Heading Here</h3>
</body>
</html>
S.No.
HTML
CSS
1.
HTML is a markup language that is to creates web page structure.
CSS is a stylesheet language that is to describes the presentation and design of web pages.
2.
You can code it only in an HTML file because its syntax only supports HTML files.
You can code it in any file format HTML, CSS, XML, etc. because it is independent of file format.
3.
It uses tags to create web content or structure.
It uses selectors or HTML tag names to give styling and for presentation.
In conclusion, we discussed the difference between HTML and CSS. We have discussed their introduction and HTML vs CSS key difference chart and their pros and cons. As well, we saw an example to understand it more clearly. Both web technologies are more useful in creating web pages. One to give it structure, and the second is to make it presentable.