No way to change font with inline styles
See original GitHub issueBrowsers have the following default css:
code {
font-family: monospace;
}
That means that currently there’s no way to change the font when using react-syntax-highlighter
without a <style>
element overriding that. If you add a fontFamily
style to the <pre>
element, it has no effect.
It seems like a good solution would be to add fontFamily: inherit
to the <code>
element, but that’d be a breaking change for some, probably.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
HTML Font Size – How to Change Text Size Using Inline CSS ...
To change the size of your text with inline CSS, you have to do it with the style attribute. You type in the...
Read more >No way to change font with inline styles · Issue #19 - GitHub
If you add a fontFamily style to the <pre> element, it has no effect. It seems like a good solution would be to...
Read more >How to change text font in HTML? - Tutorialspoint
To change the text font in HTML, use the style attribute. The style attribute specifies an inline style for an element.
Read more >Font Style does not change after adding style - Stack Overflow
The way you change a font in CSS is by doing this: ... This is called inline styling and it's generally frowned upon...
Read more >How to Change Font in HTML - HubSpot Blog
To change font type purely with HTML, use the CSS font-family property. Set it to the value you want and place it inside...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bmathews ended up implementing this as
codeTagProps
- just to satisfy other potential use cases (adding a className to the element etc…)https://github.com/conorhastings/react-syntax-highlighter/commit/a79352ad63239d6809630e23ff540a11df2950aa
so for your use case you could do something like
Let me know if this works for you!
That’s perfect! Thanks so much!