answersLogoWhite

0

A CSS class is a line of code in your CSS file which corresponds to the HTML equivalent of that class; it is defined with a dot: "."

<div class="test">This is a test.</div>

CSS:

.test { display: block; background: #f90; color: #fff; }

The classes are used to define the style for the individual element of the web page or to determine different styles for the one tag. Syntax for the classes will be the following:

Tag.Name of class { property1: value; property2: value; ... }

Inside of the style sheet the desirable tag is written first, than, after the semicolon - the user's class name. In order to define in HTML code the fact, that tag with the definite style is used, parameter is added to the tag

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach
More answers

Class defines the element's style. That way, when you have multiple elements which has the same look and style, you don't have to repeat typing in the code for style.

Example

<head>

<style>

span.blue{background-color:#0000ff;}

(.blue is the class)

</style>

</head>

<body>

<span class="blue">Blue</span>

</body>

User Avatar

Wiki User

9y ago
User Avatar

A class in CSS could be used to refer a value. A dot symbol is used to refer a class anywhere in program.

User Avatar

Wiki User

10y ago
User Avatar

Add your answer:

Earn +20 pts
Q: What is the purpose of a class in css?
Write your answer...
Submit
Still have questions?
magnify glass
imp