Forum Moderators: open

Message Too Old, No Replies

Too much inline styling in my page

         

Arturo99

3:38 pm on Jan 9, 2023 (gmt 0)

5+ Year Member Top Contributors Of The Month



what is the best way to reduce the amount of inline styling i have on my page
Almost every line is an inline style like :

<span style="color: var( --e-global-color-text ); font-family: var( --e-global-typography-text-font-family ), Sans-serif; font-weight: var( --e-global-typography-text-font-weight ); background-color: var(--nv-site-bg); font-size: var(--bodyFontSize); letter-spacing: var(--bodyLetterSpacing); text-transform: var(--bodyTextTransform)
code is bloated,
thanks

not2easy

4:38 pm on Jan 9, 2023 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Those "var(--" snippets seem to point to a javascript (or other) integration of style. You would need to look at that integration before you start trying to replace the inline style, as it is not typical inline styling.

lucy24

6:14 pm on Jan 9, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You forgot to say how the HTML is being generated. It sure doesn't look hand-rolled, so the question may be best addressed in a subforum that deals with whatever CMS you're using.

coothead

4:34 pm on Jan 10, 2023 (gmt 0)

5+ Year Member Top Contributors Of The Month



Hi there Arturo99,

to be totally blunt, I would suggest that you dump, posthaste,
whatever it is that produces that abominable excuse for code.

It should be coded like this...

HTML

<h1>
This is a -
<span>var test</span>
- for you
</h1>


CSS

:root {
--e-span-display: inline-block;
--e-span-padding: 0.25em 0.5em;
--e-font-family: arial;
--e-font-size: : 1rem;
--e-font-weight: bold;
--e-text-color: #fff;
--e-letter-spacing: 1px;
--e-text-transform: capitalize;
--e-background-color: #800;
}
span {
display: var( --e-span-display );
padding: var( --e-span-padding );
font-family: var( --e-font-family ), sans-serif;
font-size: var(--e-font-size);
font-weight: var( --e-font-weight );
color: var( --e-text-color );
letter-spacing: var(--e-letter-spacing);
text-transform: var(--e-text-transform);
background-color: var(--e-background-color );
}


You can see an example here...

Full Page View

Codepen var() example [codepen.io]

coothead

tangor

3:37 am on Jan 11, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



CSS is your best friend. The code that appeared in the OP looks like nightmare pre-CSS coding.

span has a purpose ... but every line?

I reserve the h tags for their semantic use in document layout. Otherwise I use

p.whatever formatting to replace all those span statements used back in the bad old daze! (sic)

Sgt_Kickaxe

2:15 am on Jan 12, 2023 (gmt 0)



- If Wordpress is creating it, try changing themes
- If you use a minify CSS plugin, or SEO plugin that has inline CSS capability, turn that off and see if it was converting CSS files into inline CSS.
- If a service like Ezoic is creating it, try disabling the "inline CSS" option from the minify settings tab.

It's usually one of those. Let us know what CMS software you are using for specific advice.

Also, SOME inline CSS is fine, especially if your CSS files are small. I think Bing Webmaster Tools will give you a warning if the size of your page is too big, which usually means too much inline CSS.

Good luck