Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I target CSS to a particular sharepoint Page Layout file?

Is it possible to create a .CSS file for each SharePoint Page Layout I develop, or does the CSS for each possible layout in a master page need to be referenced in the master page?

IE is it possible to affect the <head> of the page a page layout is used in?

like image 985
Loofer Avatar asked May 13 '09 16:05

Loofer


People also ask

How do I add a CSS file to SharePoint?

Applying custom CSS to a SharePoint page. You can add custom CSS to rich text fields and web part zones. To add CSS to a rich text field, put the page in edit mode and choose Insert > Embed Code from the ribbon. For web part zones, use the Script Editor web part to add HTML, scripts, or an internal style sheet.

Can you use HTML and CSS in SharePoint?

Newly released, the Script Editor web part allows you to add arbitrary CSS or HTML to any modern SharePoint page. Both techies and non-techies alike can enhance pages with custom code using simple copy/paste functionality.


1 Answers

Michal's solution can be further enhanced by including any links etc in the PlaceHolderAdditionalPageHead content placeholder tag on your layout page. This way it will be included properly in the head of the generated page.

e.g.

<asp:Content ContentPlaceholderID="PlaceHolderAdditionalPageHead" runat="server">
   <link id="Link1" href="<% $SPUrl:~SiteCollection/Style Library/mystyle.css%>" runat="server" type="text/css" rel="stylesheet" />
   <SharePoint:ScriptLink id="jQueryCore" language="javascript" name="ui.core.js" runat="server"/>
</asp:Content>
like image 111
Mark Avatar answered Oct 13 '22 15:10

Mark