Issues running HTML and CSS code simultaneously in Visual Studio Editor.
How can I add custom CSS styles to VS Code? - Stack Overflow
html - Having problem with running my CSS on VS Code - Stack Overflow
Can't create a CSS file in Visual studio Code - Stack Overflow
Videos
(I am trying to build a multi-page website for shits and giggles)
This question probably has a very simple answer.
I started coding a few hours ago, I have figured out how to code ( very rudimentary ofc) HTML, and CSS... the two codes work fine together in a codepen... but I can not figure out how to get it to work in "Microsoft's visual studio code" (VSC)
I was learning on code pen but want to continue on a more substantial editor... furthermore, I have had luck, not perfect, implementing CSS code directly into the HTML, but I would rather have separate files so I can have a single CSS dictate the laws of style.
I was very excited (to show where I am at knowledge-wise) when I got my first HTML single text code to open up in a chrome tab.
SO when I run the HTML and CSS code in parallel with each other on Codepen... it works swimmingly... it only loads the HTML content and not my CSS code when on VSC
any help would be greatly appreciated
You currently can't do this without "performing surgery on VS Code" so to speak. VS Code colour themes don't allow arbitrary / custom CSS.
Workarounds
You can take a look at extensions like be5invis/vscode-custom-css, subframe7536.custom-ui-style, or drcika.apc-extension (I have no affiliation with these extensions). The first one basically provides a configuration point for you to specify paths to CSS files you want to be imported into VS Code's own CSS files, and modifies your VS Code installation's files to import those files, which will cause VS Code to issue a corruption warning, since it performs startup checks to see if its installation has been tampered with (probably for security reasons to protect you, and which you can mark to not be shown again through the gear button menu).
Why VS Code chooses not to add such a feature
I googled "site:github.com/microsoft/vscode/issues custom css" and found Simple CSS Editor Customization
#106750, which points toward Add some API to support GUI customization #1833, where exploring the linked tickets leads to Support user stylesheet(s) and user script(s) #459, which has a comment pointing to a rationale for why the VS Code team decided not to accept a Pull Request which implemented such a feature:
Thanks for this PR but we decided to not allow these kinds of modifications to our CSS directly. Rather, we think that our theming story should be evolved to allow more user configurations. See #26128, #26129 and #26130 for example.
The two main issues with this approach here is:
- basically this makes all of our CSS class names API (in the same way all of our themable colors have become API). we do not want to commit ourselves to keeping the CSS class names stable. rather we should find those styles that we want to make themable and then explicitly announce them as API (same as we did and do for colors)
- the other issue is that bug reports we receive will be harder to understand if users run with custom CSS changes that we are not aware of. we think that we should be in control of which user styles can be changed and provide explicit support for instead of opening the door to any CSS changes that are possible with this approach
See also https://www.hyrumslaw.com/.
@2025-04-06 The latest solution is to use the Custom UI Style plugin. For specific setup methods, please refer to https://github.com/subframe7536/vscode-custom-ui-style/issues/41.
Here are my steps:
- install the Custom UI Style extension in Vscode
- Set similar code as below in settings.json.
"custom-ui-style.webview.stylesheet": {
"h2": {
"color": "#ff6f61"
},
}
Then it works
It appears that you have successfully created the CSS file in the directory where your index.html is present. Just write the CSS in it and if the styles are not applied then check if you have linked the CSS file correctly to the html or not. With your current setup you can link it with this link tag:
<link rel="stylesheet" href="style.css" type="text/css">
Put this link tag within the head tags
the "#" is the basic icon in VSCode to define a css file, did you link your css to your html?
<link rel="stylesheet" href="./style.css">
I’ve been working on this custom CSS setup for VS Code for a while, and it's almost complete. I thought I'd share it with others, and any suggestions or feedback would be greatly appreciated!
inspirations:
creator: LunDev
creator: Glenn Raya
just ignore the arch girl 😅.