I've already done my research on "Specificity Explained" sites and need a real explanation as to why my selector isn't overriding the default styles.
My goal is to modify certain attributes of the following selectors from Site.css:
.dl-horizontal dt {
float: left;
width: 43%;
overflow: hidden;
clear: left;
text-align: right;
text-overflow: ellipsis;
white-space: nowrap;
font-size: .9em;
}
.dl-horizontal dd {margin-left: 45%; font-size: .9em;}
Here's what I'm trying to do directly on the web page:
<style>
/* Using 2 classes for higher specificity */
.gwx_override .gwx_dt2 {
width: 25%;
}
.gwx_override .gwx_dd2 {
margin-left: 27%;
}
</style>
The rendered HTML looks like this:
<dl class="dl-horizontal">
<dt class="gwx_override gwx_dt2">Notes</dt>
<dd class="gwx_override gwx_dd2">Once more rejecting this tag.</dd>
</dl>
I expected my overrides to take precedence over the site.css selectors, especially since my specificity is higher. However, browsers like Firefox and Chrome keep prioritizing the original styles.
The browser inspectors show ".dl-horizontal dd" with specificity of 0.1.1 compared to mine at 0.2.0 - so shouldn't my styles be applied?
What confuses me is that the browsers are not even displaying my selectors in the list of overridden rules, leading me to think there might be an issue with my CSS syntax. But after checking it with validators, they confirm it's correct.
For additional context, here's the top part of the page where my selectors are defined and Site.css is referenced within an ASP.NET webform:
<html class="no-js" lang="en">
<head id="hdMain"><meta charset="utf-8" /><title>
Tag Confirmations
</title><meta name="author" content="na" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><meta name="google" content="notranslate" /><link rel="shortcut icon" href="../Resource/img/favicon/favicon.ico" />
<style>
.gwx_dt
{
font-size: 1.1em;
text-align: right;
}
.gwx_dd
{
text-align: left;
}
/* Using 2 classes for higher specificity */
.gwx_override .gwx_dt2
{
width: 25%;
}
.gwx_override .gwx_dd2
{
margin-left: 27%;
}
</style>
<script src="/Resource/js/libs/jquery-1.8.2.min.js" type="text/javascript"></script>
<script type="text/javascript">window.jQuery || document.write('<script type="text/javascript" src="/Resource/js/libs/jquery-1.8.2.min.js"><\/script>')</script>
<link href="../App_Themes/Default/css/bootstrap.min.css" type="text/css" rel="stylesheet" /><link href="../App_Themes/Default/css/bootstrap-responsive.min.css" type="text/css" rel="stylesheet" /><link href="../App_Themes/Default/css/button.min.css" type="text/css" rel="stylesheet" /><link href="../App_Themes/Default/css/font-awesome.min.css" type="text/css" rel="stylesheet" /><link href="../App_Themes/Default/css/Site.css" type="text/css" rel="stylesheet" /><link href="/WebResource.axd?d=dhMRE7UEy7H080vdET4SQ5gaXv3yKJxFKjw0WJwjMOJXb_3uiqKz9iCutRYXNgczGznC3Qji1bVmCcREwl3gmsg89VoYWHoI5c1ffKReC3pa3UBDEov8wgpZH1tZNKBOHQZdm83u3WzAOZRlifWwtA2&t=635918956660000000" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=yO7Hnfif15zu3ajS_Kv2hIZOq3KB4gvK7aVCCwgBWFENha719NSIfzrGlrQmOaMbT8haRIkp-BPrOzfsg4dlULpKvYjYf3zDPnkD0cYbLIxpUFaZYBVOqIErAAKOOl9gU2z91bzHaLJALgMqeYlZuqhaA4YlMWbxsM2WvZG7MFM1&t=635918956660000000" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=M9dREq2pa3GD5R-MuoMAJO7TmjJQI86OXZMFLhRqz_lACLMSoj31CToFGgrCmBuC8hR-6n8Nsb78eYTdJebJ3vh71y1K0SEw9iq8oSh4pZJNt7iaAn0jOyUXAY3zQnWTronjbqmiQZPuoWnBJ3moKA2&t=635918956660000000" type="text/css" rel="stylesheet" class="Telerik_stylesheet" /><link href="/WebResource.axd?d=SLj6-zA4DTwqZ1ti9zYnP0U_Uz8SW1QJifMiNIveIpk6-jnuMHgIJbfScDBCpKbHN1hzAXHzgveilPMaHHpJ1MYssBokKNa0ILKEVLsKQIEIb-bkabQM2bFQI77lHSkWKcRGgFkFIgGxlG8Fa0prPdMgwjs4lr3lDFP2G7vb7ZY1&t=635918956660000000" type="text/css" rel="stylesheet" class="Telerik_stylesheet" />
</head>
<body>