What are the three main ways to add CSS to a webpage?
Experience Level: Junior
Tags: CSS
Answer
- External style - link
<html>
<head>
<title>External style for CSS</title>
<link rel="stylesheet" type="text/css" href="html-cheat-sheet.css" />
</head>
<body>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
</body>
</html>
- In-line style - atribut
<html>
<head>
<title>In-line style for CSS</title>
</head>
<body>
<p style="color: red">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
</body>
</html>
- Embedded style
<html>
<head>
<title>Embedded style for CSS</title>
<style>
p {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #ff9900;
}
</style>
</head>
<body>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
</body>
</html>
Related CSS job interview questions
What is a CSS preprocessor?
CSS MediorWhat are CSS media queries? And what are they use for?
CSS JuniorWhat are the Sprites in CSS?
CSS JuniorWhat are the various techniques for clearing floats?
CSS JuniorWhat is “reset” CSS file?
CSS Junior