Using # or "." ?

Hi all,

I am using WordPress to build a site...and

I see some CSS code in the style.css file.

Some of it begins with a # or .
before the command.

FOR EXAMPLE
#header {
padding: 0;
margin: 0 0 0 -20px;
background: #fff;
width: 980px;
}

NOW...can someone use this as well?

.header {
padding: 0;
margin: 0 0 0 -20px;
background: #fff;
width: 980px;
}


NOW...can someone use this as well?
Will the effect be the same?

thanks for your help!

Comments

  • The dash (#) is used for id's while the dot (.) is used for classes. Example:
    #header { width: 100px; height: 100px; border: 1px solid #000; color: #00f }
    .header { color: #f00; font-weight: bold }
    
    <div id="header">
      <span class="header">Text with</span> and without the header class.
    </div>
    
  • Thank you Pritaes!
  • To go further, ID's (#) are #unique, and thus are only suppose to appear once on your site. On the other hand, .classes can appear multiple times and are used for common elements among multiple pages.
Sign In or Register to comment.