Jump to content

Recommended Posts

a "." is for a class, you can use this as much as you want in one page

a "#" is for an id, you can only use this once on each page

<div id="wrapper">

<div class="green">This is green text</div>
<div class="green">This is green text</div>
<div class="green">This is green text</div>

</div>

I didn't include the css...but I think you'll get the idea.

-Chris
Link to comment
https://forums.phpfreaks.com/topic/34813-class-and-class/#findComment-164119
Share on other sites

To go a little further,

Say you had a generic class called red

[code].red{
  background-color:#902100;
}[/code]


[code]
<li class="red"></li> ..
<td class="red"></td> ..
<span class="red"></span> ..
<span class="blue"></span> ..[/code]
[list][*]You code apply that to many types of tags.[/list]

If you wanted to beforehand in the css, you could call them out by tag and id.

[code]span .red{  font-size:1.6em;  }[/code]
[list]
[*]This line only effects spans that are "red"
[/list]

[i]tag & class[/i] are one way to further divide class and id. It all depends on how many children you want your elements to have. Inheritence.

I try to use classes for things that I'll most likely reuse, and ids for the known one-timers.
That said, the more I use javascript, the more that I'm dropping [b]id[/b]s all over the place. I'll try to find a way to style away from the script. The last thing you need is style and javascript breaking together.

Link to comment
https://forums.phpfreaks.com/topic/34813-class-and-class/#findComment-165498
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.