CodeClerks

What is a class?



Write the reason you're deleting this FAQ

What is a class?

In reference to a CSS file, what is a class?

Comments

Please login or sign up to leave a comment

Join
Alast
A class is essentially an object.

.class {

}


That would result in nothing, but if you were to add a background-color or anything, then that object will turn into something useful for your website. That being said - classes do not have to contain any visual aspects. They can be used to wrap other classes to ensure everything fits nicely together when resizing your screen.



Are you sure you want to delete this post?

ankitagupta339
Class is used when we want to write properties like text align, color width etc.



Are you sure you want to delete this post?

jakemadness
Some people don't realize a CSS class is used for styling more than one HTML element in your page, a CSS id can be placed on only one HTML element in your page otherwise it will be marked as invalid by w3 validator many people make this mistake What is a class?

Valid:

<style type="text/css">
.class
{
   color: #222;
}
</style>
<span class="class">first element</span>
<span class="class">second element</span>
 


InValid:

<style type="text/css">
#id
{
   color: #222;
}
</style>
<span id="id">first element</span>
<span id="id">second element</span>
 



Are you sure you want to delete this post?

AjayPrasad
In the CSS, a class selector is a name preceded by a full stop (“.”). You can also define your own selectors in the form of class.
.class1 {
color: red;
font-weight: bold;
}
The HTML refers to the CSS by using the attributes class
<p class="class1">This is class1 selector of class attribute in Paragraph tag</p>



Are you sure you want to delete this post?