Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add html Element Attributes in react

Tags:

html

dom

reactjs

How can I add an attribute to html element in React js. I want to set <html lang="en"> to solve WCAG Level A validation issue.

I added html-element-attributes module but no idea about how to use it.

Anybody please help to get a way to add this lang attribute to html element?

like image 848
Prajila V P Avatar asked Sep 03 '25 02:09

Prajila V P


1 Answers

you need React helmet for this. Put this block in any top level component's render:

<Helmet>
  <html lang="en" />
</Helmet>
like image 180
Fawaz Avatar answered Sep 04 '25 23:09

Fawaz