Jump to content

(#) and (.) classes

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
k4m1k4z1

k4m1k4z1

    Learning Programmer

  • Members
  • PipPipPip
  • 38 posts
Hello forum, I was looking at some css and i noticed on their stylesheet that they had some that were like "#footer" and some that were like ".footer". These are just examples but i am wondering what the difference is between the two. Help appreciated.
:D

k4m1k4z1:pinguin:

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
There are two different ways to identify an HTML element: ID and Class. An HTML element can only have one ID, but multiple classes. Each ID should only be applied to one element, but a class can be applied to multiple elements. In CSS, # is used for an ID, . for a class.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
k4m1k4z1

k4m1k4z1

    Learning Programmer

  • Members
  • PipPipPip
  • 38 posts
Thank you for your help, I was looking for an answer for quite some time now. I really appreciate your help.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Glad I could help :)
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
Howdy_McGee

Howdy_McGee

    Programmer

  • Members
  • PipPipPipPip
  • 135 posts
I have a similar question:

Why is it that in some instances styles applied to classes won't be applied but using ids: the style will apply?
I recently had a situation where classes wouldnt pass the styles to the multiple elements but once i used multiple ID's the style worked perfectly.

#6
niggoo

niggoo

    Newbie

  • Members
  • Pip
  • 5 posts
Two examples:

<div id="something"></div>
CSS: #something {}

<div class="something"></div>
CSS: .something {}