Using @Yarnabrina's solution, I've added the styling for something simple like changed the text color to blue.
When I opened the developer tools, I found that the side note is rendered into a <span> element with the class .sidenote. I created a css file (styles.css) and placed in in the same directory as the Rmarkdown file. Here's the css.
.sidenote {
color: blue;
}
CSS files can be linked in the YAML using the css param. If you were to use the Tufte theme, it would look like this.
---
title: "TRYING OUT TUFTE HANDOUT STYLE"
output:
tufte::tufte_html:
css: "styles.css"
tufte::tufte_handout: default
---
The Tufte theme is fairly opinionated in terms of layout and design. Using ^[some text] would render as a footnote in other themes rather than a side note. Technically, all side notes should be rendered in the html element <aside> rather than a <span> for good semantic HTML practices. However, there isn't a good way to add <asides> in markdown. Instead, you will have to open and close the tags manually: <aside>my sidenote</aside>, and then style the aside element in the css file. This might not be ideal, but it would be a way to replicate the same layout if you weren't using the Tufte theme.
First, here's how you would create an <aside> (using the same text and updated yaml)
---
title: "TRYING OUT SIDENOTES"
output:
html_document:
css: "styles.css"
---
more random words <aside>adding a sidenote</aside>
In the css file...
aside {
float: right;
color: blue;
}
Hope that helps!