Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8676911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:19:03+00:00 2026-06-12T20:19:03+00:00

#main { background: #000; border: 1px solid #AAAAAA; padding: 10px; color: #fff; width: 100px;

  • 0
#main {
    background: #000;
    border: 1px solid #AAAAAA;
    padding: 10px;
    color: #fff;
    width: 100px;
}
<div id="main">
    Welcome
</div>

Here I gave an id to the div element and it’s applying the relevant CSS for it.

OR

.main {
    background: #000;
    border: 1px solid #AAAAAA;
    padding: 10px;
    color: #fff;
    width: 100px;
}
<div class="main">
    Welcome
</div>

Now here I gave a class to the div and it’s also doing the same job for me.

Then what is the exact difference between Id and class and when should I use id and when should I use class.? I am a newbie in CSS and Web-design and a little bit confused while dealing with this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:19:05+00:00Added an answer on June 12, 2026 at 8:19 pm

    For more info on this click here.

    Example

    <div id="header_id" class="header_class">Text</div>
    
    #header_id {font-color:#fff}
    .header_class {font-color:#000}
    

    (Note that CSS uses the prefix # for IDs and . for Classes.)

    However color was an HTML 4.01 <font> tag attribute deprecated in HTML 5.
    In CSS there is no “font-color”, the style is color so the above should read:

    Example

    <div id="header_id" class="header_class">Text</div>
    
    #header_id {color:#fff}
    .header_class {color:#000}
    

    The text would be white.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My css code: .main-slider{ background-color: #CCC; border: 1px solid #000; width: 650px; height: 300px;
.cornerBox { background: url(../img/main-part.png) repeat-x top left ; width: 400px; height:100px; border-radius: 80px; padding:
What is the difference between # and . with CSS? #main { background-color: #fff;
I want to change the background color of our apps main window when a
my html code <div id=content_main></div> css #content_main { width:1024px; height:150px; background:url('../images/Orange.jpg'); background-repeat:no-repeat; background-size:1024px 150px;
I have this little mixin set up: .linear-gradient(@direction:top, @color1:#fff, @color2:#000) { background-image: -webkit-linear-gradient(@direction, @color1,
My problem is that the border for the main div doesn't extend to the
http://jsfiddle.net/nUcXQ/ How to get dynamic height on the main (black background) I'm using image
Background The main application where I work is based heavily on the MUMPS-esque Caché
Background I'm configuring a custom WSS application that focuses around one main list. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.