ExpertiseKnowledgeToolsField GuideBlogAbout
← pH7x KnowledgeSharePoint

How to inspect the alternate CSS of a SharePoint site

Does this site load a custom stylesheet into every page?

By João Livio·pH7x Knowledge

30-second answer

powershell
$web = Get-PnPWeb -Includes AlternateCssUrl
if ([string]::IsNullOrWhiteSpace($web.AlternateCssUrl)) { "None" }
else { $web.AlternateCssUrl }

What this proves

Whether the site is configured to inject a custom stylesheet into its classic pages, and which file it is.

What it does not prove

  • What the stylesheet changes. The property stores a path, not the intent behind it; the file may recolour a banner or restructure the whole chrome. Reading the CSS itself is a separate step.
  • That modern pages are affected. They are not: alternate CSS applies to the classic experience. Its presence tells you about the site's past, and about what classic pages still look like.

PowerShell

powershell
Get-PnPWeb -Includes AlternateCssUrl, MasterUrl |
  Select-Object @{n='AlternateCss'; e={ $_.AlternateCssUrl }},
                @{n='MasterFile';  e={ Split-Path -Leaf $_.MasterUrl }}

Read it together with the master page: the two are the classic branding pair, and a site with either has been deliberately styled.

Example output

text
AlternateCss                              MasterFile
------------                              ----------
/sites/intranet/Style Library/corp.css    seattle.master

Explanation

An empty value is the answer on most sites, and empty means observed-empty: the property loaded and there is no stylesheet. A populated value means somebody invested in classic branding, and that investment is the part of a migration that does not carry over. Modern sites express branding through themes and site designs; a corp.css does not translate, it gets rebuilt or retired.

Production considerations

  • Load with -Includes; an unloaded property returns null and is indistinguishable from "no stylesheet" unless you asked for it.
  • The path may point at the Style Library of the site or of another site. A stylesheet hosted centrally means the branding, and the blast radius of changing it, is shared.

References