Adding a .css file into sharepoint

16,444

Solution 1

Both of those will work, however the CSS may get executed AFTER the SharePoint Page is rendered.

The short and simple way is to add the CSS file to any document library (Style Library too). Add the Link script above into a text file and upload that. Add a Content Editor Web Part to the page and through the settings, point it to the TEXT file with the script.

The CEWP part is executed during the HTML creation process when building the page thus the CSS gets executed with the header (like the rest of the CSS for SharePoint).

Solution 2

Try adding your .css file to your main web "Style Library"

Solution 3

You need only to publish your css file

  • Go to your all document view
  • find your file
  • publish
Share:
16,444
Jamie Hutber
Author by

Jamie Hutber

I'm just trying to learn and then eat some food.

Updated on June 04, 2022

Comments

  • Jamie Hutber
    Jamie Hutber almost 2 years

    I am trying to include this line of html into a sharepoint 2007 content section inside a page i have just created. I am the owner.

    <link rel="stylesheet" type="text/css" href="/sites/gskglobal/mcLaren-partnership/Documents/live.css" />
    

    I input this using Edit HTML Source on a piece of content (This was the only way i could find out how to input HTML directly).

    When i click ok the styles display perfectly having already uploaded the css file.

    When i click save it removes the entire link element and leaves me with no stylesheet.

    i could put the styles in line, but i really don't want to do this.

    N.B no erros are displayed only

    Warning: The HTML source you entered might have been modified.

  • Jamie Hutber
    Jamie Hutber over 11 years
    where would i find this style library? I haven't worked with this mammoth beast before.
  • Mhd. Yasseen
    Mhd. Yasseen over 11 years
    It should be on your root site.
  • Jamie Hutber
    Jamie Hutber over 11 years
    I can't find anything that looks like a style library. I have found whilst in edit mode under the page tab a button called library settings, but then searching for style in this brings up nothing
  • Mhd. Yasseen
    Mhd. Yasseen over 11 years
    Go to your main web, click all site content, and if you have sufficient permissions you would be able to find Style Library under "Document Libraries". Alternatively you can go to [12]\TEMPLATE\LAYOUTS\STYLES and add your file manually, then add the href='_layouts\styles[filepath]'
  • Jamie Hutber
    Jamie Hutber over 11 years
    It would appear i don't have permissions to this. I sure as hell can't get to the root of the server. But i have looked as per your suggestion, thanks for that :) I will have to scratch around more, but looks like inline styles are calling.
  • David Sterling
    David Sterling about 11 years
    You can do this but be aware that if you add styles to that library, they are loaded every time you hit the page (it's a separate file request). In many cases you will not have access to this if you are not the Site Owner. In addition, many of your users will not either - a big problem - you have to grant all users read to this or give them Style Readers membership (they usually are by default, but all depends on how protective the admin is). The library is a document library located at http://<site>/Style Library. You can either navigate to this or find it using Designer. I don't recommend it