MyBB Community Forums

Full Version: Adding classes to the html tag
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm trying to add some classes to the html tag for some conditional styles but MyBB seems to be replacing it with the default xhtml html tag, I've hooked onto the pre_output_page hook which you'd expect to be AFTER MyBB's fiddled with it.

Does anyone know how to do this?
did you try to add the class to the body tag?
(2011-10-06, 07:34 PM)patrick Wrote: [ -> ]did you try to add the class to the body tag?

It won't have the same effect, I wouldn't be able to style the html element for one.
If you only need to add some style to the html tag globally, use:
html {
color:red;
/*CODE*/
}
or add the CSS in the head
(2011-10-06, 08:56 PM)Sama34 Wrote: [ -> ]If you only need to add some style to the html tag globally, use:
html {
color:red;
/*CODE*/
}

I have conditional css, meaning instead of having 2 proper themes, it's sort of a "sub theme"
For example
p {
 /* Normal CSS */
}
.night p {
 /* Different CSS */
}

The reason why putting the class on the body tag wouldn't work is that for example,
html{
 background:blue;
}
html.night { /* Note that the class must be on the HTML element */
 background:orange;
}

That wouldn't work properly on the body tag.
That's why I said to put in into the head. A plugin can easily insert between <head></head>
<style type="text/css>html { background:blue; }</style>
If you need to add a class as well, you can add that to the body element. Every element except HTML inherits the body, so the result is identically as if you've classed the HTML.
Why do you want to class the HTML tag in the first place?
Adding a class to the html tag surely is not semantic at all. In fact, I've never seen anybody actually do it.... Just add a class to the body - you can likely do what you want to do there anyway.
(2011-10-06, 11:03 PM)Bugster Wrote: [ -> ]The reason why putting the class on the body tag wouldn't work is that for example,
html{
 background:blue;
}
html.night { /* Note that the class must be on the HTML element */
 background:orange;
}

That wouldn't work properly on the body tag.

(2011-10-07, 07:28 PM)euantor Wrote: [ -> ]Adding a class to the html tag surely is not semantic at all. In fact, I've never seen anybody actually do it.... Just add a class to the body - you can likely do what you want to do there anyway.


(2011-10-07, 07:29 AM)patrick Wrote: [ -> ]That's why I said to put in into the head. A plugin can easily insert between <head></head>
<style type="text/css>html { background:blue; }</style>
If you need to add a class as well, you can add that to the body element. Every element except HTML inherits the body, so the result is identically as if you've classed the HTML.

It's a lot of html to be put inline, and it bypasses the CSS minifying if it's not put into an external css file.
Pages: 1 2