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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:02:44+00:00 2026-05-28T19:02:44+00:00

As I understand it, a class should take precedence in styles over the element

  • 0

As I understand it, a class should take precedence in styles over the element styles. I’ve tried to style button, input[type=button], and input[type=submit] and noticed that with the input (button and submit), the border style from the element would take precedence over the border style for the class. I did not notice this behaviour, however, on the button element.

Here’s an example demonstrating the situation:

<!DOCTYPE html>
<html>
<head>
    <title>Page Title</title>
    <style>
        input[type=button], button {
            border: none;
        }

        .class {
            border: 1px solid red;
        }
    </style>
</head>
<body>
    <input type="button"  class="class" value="With class" />
    <input type="button" value="Without class" />
    <button class="class">With class</button>
</body>
</html>

The above renders like this:

I’ve noticed the same behaviour in Safari, Firefox, and Chrome.

Am I doing something wrong? Have I misunderstood specificity in this case? Is this specific to border only?

  • 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-28T19:02:45+00:00Added an answer on May 28, 2026 at 7:02 pm

    You’re not comparing apples to apples. Attribute selectors have a specificity of 0,1,0 just like classes. However, element selectors have a specificity of 0,0,1, which makes your first selector of input[type="button"] have a specificity of 0,1,1 which is greater than 0,1,0.

    http://www.w3.org/TR/CSS2/cascade.html#specificity

    If you wanted them both to have the same specificity, you should use:

    input.class
    input[type="button"]
    

    -or-

    .class
    [type="button"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't understand the class TextCompositionEventArgs. There are members of type string named ControlText,SystemText,Text.
I would like to understand what class << self stands for in the next
Veterans please forgive me for asking silly question. I understand that a class having
I understand the need to test a class that has logic (for instance, one
I understand one uses the bless keyword in Perl inside a class's new method:
I understand that one can raise an event in the class that the implementation
I understand that CoCreateInstance finds the COM server for the given class id, creates
I understand overriding a method/function redefines its implementation in the derived class from its
I understand and appreciate the usefulness of the System.WeakReference class in the .NET framework,
I understand how the new keyword can hide methods in a derived class. However,

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.