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 7649431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:57:45+00:00 2026-05-31T10:57:45+00:00

Hello, I have seen a strange behavior while using CSS HTML selector and class

  • 0

Hello,
I have seen a strange behavior while using CSS HTML selector and class selector.
in HTML file I have this code:

<div class="content">
    <h1>Registration Form</h1>
</div>

And in Css file I have:

.content
{
    margin:auto;
    width:600px;
    border:solid 1px black;
    background-color:White;
    padding:10px;
}

h1
{
    color:Gray;
    font-size:18px;
    border-bottom:solid 1px orange;
}

Above code works perfectly.
When I changed h1 HTML selector to Class selector by writing .h and h1 class="h" STILL it worked perfect.

BUT
when I changed .content class selector to div (ie I converted class selector of div tag to DIV HTML selector ITSELF) then the output changed.
It did not show me the text Registration form at all and showed horizontal lines above and below the area where Registration form text would be present.
why is this strange behavior?

Does it proves that class selector and HTML selector behave differently even if applied with SAME style rule effect?

  • 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-05-31T10:57:46+00:00Added an answer on May 31, 2026 at 10:57 am

    A class selector is more specific than a type selector.

    When you change the type selector to a class selector, the first selector still has precedence, just because it comes first.

    When you change the first class selector to a type selector, the second selector becomes more specific, and takes precedence.

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

Sidebar

Related Questions

I am new to programming.I have seen this code.returning a derived class object to
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
Hello I have been having trouble with this for a while now. I have
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
I have seen many samples of Ruby code with this line (for example, http://www.sinatrarb.com/
I have seen the run_once method in some code like run_once do [:hello, :core,
I have seen sample code similar to the following: std::string s = Hello World!;
Hello i have created a sample application in android using eclipse IDE my code
Hello I have the following code to retrieve data from my db using nhibernate
Hello I have a question recently I seen more and more sites using #/pagename

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.