Link to home
Create AccountLog in
Avatar of Aleks
AleksFlag for United States of America

asked on

Apply css to page when page loads

I have a page that calls a css linked file
the css has elements that can be applied to the page, but I want the page to apply margins when it loads:


.body {
      margin-left: 5px;
      margin-top: 5px;
}


.bodytext {
      font: 11px/15px Tahoma, Arial, Helvetica;
      color:#363636;
      font-style: normal;
}

.bodytextR {
      font: 11px/15px Tahoma, Arial, Helvetica;
      color:#363636;
      font-style: normal;
      text-align: right;
}


The bottom two elements need to be applied to a region, the top I want to apply to all pages linked this css, so that the .body is applied to the PAGE on load, and not to a specific element, how to do this ?
Avatar of WebDevEM
WebDevEM
Flag of United States of America image

If I'm understanding the question correctly, all you would need to do is remove the period from in front of ".body" so that it isn't looking for an element with the class of body, but the actual body itself.  That way, any file which calls this CSS file would get your margins applied automatically without having to add class='body' to your HTML.
Avatar of Aleks

ASKER

So all I need to do is delete the dot to apply it automatically to the whole page?
Avatar of Aleks

ASKER

tried that but the page didnt apply that body margins to the page when it loaded.
Avatar of Aleks

ASKER

This are the two first elements of my .css file:

----

body {
      margin-left: 5px;
      margin-top: 5px;
}

.bodytext {
      font: 11px/15px Tahoma, Arial, Helvetica;      color:#363636;
      font-style: normal;
}

-----

the body margins are not applied to the page  :(
Avatar of Aleks

ASKER

I am having to do this in my ASP page to make it work:

<link href="../../css/CMS.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {
      margin-left: 5px;
      margin-top: 5px;
}
</style>

instead I want to include the body part inside the CMS.css file so I can get rid of that part of the code since I use it in every page.
ASKER CERTIFIED SOLUTION
Avatar of captain
captain
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Aleks

ASKER

It was being overiden. Ill check and get back here later if needed.
Moving that inline CSS into the CMS.css file should work... do other styles get applied, so you know that the CSS file is being loaded?
Thanks very much :)