Jump to content

Differences between "#.exa" and only ".exa"


LeonLatex
 Share

Go to solution Solved by requinix,

Recommended Posts

A while ago I got an answer to the difference between .class and .id. Got a good and understandable answer there. The following question goes on almost the same. 

After <style>  why does someone put only a * in front of a {  What does this mean?

Then there are two other things.

I usually enter, for example, a class for a div, for example like this:
div.font but then I see there are others who do not put anything in front .font - what is the difference?
Other times, some enter only a # .font

Link to comment
Share on other sites

  • Solution
1 hour ago, LeonLatex said:

After <style>  why does someone put only a * in front of a {  What does this mean?

* means any element.

1 hour ago, LeonLatex said:

I usually enter, for example, a class for a div, for example like this:
div.font but then I see there are others who do not put anything in front .font - what is the difference?
Other times, some enter only a # .font

div.font only applies to DIVs with a "font" class while .font applies to any type of element with a "font" class.

# is for IDs.

These are fairly basic CSS questions...

Link to comment
Share on other sites

Posted (edited)
On 3/29/2022 at 4:11 PM, requinix said:

* means any element.

I thought so, but i had to ask to be sure.

div.font only applies to DIVs with a "font" class while .font applies to any type of element with a "font" class.

I am aware of that. I dont think that was part of the questions 😊👍 (Sorry requinix. I read your answer one more time and understood i missed the meaning about .font . Actualy that was what i was asking about 😂😂🤓👍

# is for IDs.

These are fairly basic CSS questions...

Ok. That didn't tell me much other than # is for ID's, and you have told me before requinix that ID can only be used on one place or one time (or something like that). Right requinix? But what does the # do/tell to do in a ID?

Appreciate you help and your teaching requinix. Thank you 😊

 

Edited by LeonLatex
Link to comment
Share on other sites

3 hours ago, LeonLatex said:

But what does the # do/tell to do in a ID?

The # just signifies an ID, like how . signifies a class. 

So #font would be whatever element has the attribute id="font", while .font would be any element with class="font".  ID's must be unique within a document, classes can be reused any number of times.  ID's also have a higher priority than classes in the case of conflicting rules.

You should probably just read up on CSS Selectors and get familiar with them.

 

  • Great Answer 1
Link to comment
Share on other sites

13 hours ago, kicken said:

The # just signifies an ID, like how . signifies a class. 

So #font would be whatever element has the attribute id="font", while .font would be any element with class="font".  ID's must be unique within a document, classes can be reused any number of times.  ID's also have a higher priority than classes in the case of conflicting rules.

You should probably just read up on CSS Selectors and get familiar with them.

 

You saved me a lot of time, so i don't have to use time on reading me up on 5 pages describing the answer it takes only 4 lines to describe. Thanks, kicken 👍😊

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.