[Solved] User agent stylesheet overriding my table style? Twitter Bootstrap

I’m using twitter bootstrap. My problem is that font-sizes in tables are wrong. For some reason the User Agent stylesheet is overriding the bootstrap table styles.

On the twitter bootstrap page (http://twitter.github.com/bootstrap/base-css.html) everything is of course working correctly.

In my inspector I see the following difference:

My page:

CSS style for my page

The twitter bootstrap page:

CSS style for twitter bootstrap page

So definitely the problem is that the user agent stylesheet is overriding the bootstrap styles.

I haven’t been able to figure out why this is different on my page and the twitter bootstrap page.

Most of the other CSS is working fine.

My css import:

<link href="/media/bootstrap/css/bootstrap.css" rel= "stylesheet">

CSS import on twitter bootstrap page:

<link href="assets/css/bootstrap.css" rel="stylesheet">
Enquirer: Riku

||

Solution #1:

I actually figured this out myself. I had the <!DOCTYPE html> tag wrongly written. So if you have this problem make sure the doctype declaration is correct!

Respondent: Riku

Solution #2:

Please import the docs.css into your application as well. If I must say so, you must have realized that the Twitter Bootstrap Docs are using bootstrap.css and a custom docs.css. Try doing, which you can download from the github package. Then, try playing around with the table classes in docs. css without messing with the master css. Or try adding DOCTYPE in headers.

<link href="/media/bootstrap/css/docs.css" rel= "stylesheet">
Respondent: Ali Gajani

Solution #3:

If declaring <!DOCTYPE html> in the very beginning doesn’t work, then it’s probably not your user-agent style sheet casuing it. It may be Bootstrap’s style sheet overriding your styles (I’ve had this problem). Make sure your style sheet is linked to after Bootstrap’s style sheet in your HTML.

<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/mystylesheet.css" rel="stylesheet"> <!-- Your custom style sheet goes after Bootstrap's -->
Respondent: bgashler1

Solution #4:

I had the same issue as the OP. I wanted lovely small text and some user stylesheet was overiding it and putting:

font-size: medium;

When I wanted:

font-size:8pt;

I placed the following at the top of my HTML page:

<!DOCTYPE html>

All was good then, a bad habit to get into to not declare doctype at the top. All user stylesheets have now gone.

To discover what is overriding what on your CSS it is always a good idea to inspect element (F12) and you can modify and untick attributes on the fly until you get to right, then update your CSS file with it!

However if you do have a user stylesheet issue, these values will be locked.

Respondent: Rmj86

Solution #5:

Check whether your CSS is called or not in browser dev tools (press F12) under network column.

If it is not called, use your style sheets with1 rel="stylesheet" type="text/css".

It worked for me.

Respondent: Ravikumar K

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.