• Please note that this section is for questions regarding the forum itself - it is not for fan game-related questions. If you have a question about a fan game, ask in the appropriate thread.

  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Suggestion: Scoped Styles

Touched

Resident ASMAGICIAN
  • 625
    Posts
    10
    Years
    • Age 123
    • Seen Feb 1, 2018
    The [div][/div] and other CSS tags result in some really ugly markup. Would it not be possible to grant scoped styling (so that It can't leak out and affect the surrounding styles) with something like

    Code:
    [PLAIN]
    [scoped]
    [style]
    .my-class { color: red: }
    [/style]
    
    [class="my-class"]Whatever[/class]
    [/scoped]
    [/PLAIN]

    This could be implemented using

    HTML:
    <div class="scoped">
    <style scoped>
    .my-class { color: red }
    </style>
    <span class="my-class">Whatever</span>
    </div>

    Or using an Iframe for maximum browser support (with srcdoc, a data url containing html or some external html file generated from the inner BBCode)

    HTML:
    <iframe class="scoped" seamless="seamless" srcdoc="...">

    This would just allow for cleaner and reusable CSS inside a thread, and maybe hover effects or other things that are not currently possible.
     
    The reason I haven't implemented this for all users with BB code is that I'm not confident about its safe usage, especially with browsers that haven't implemented it properly. And we're certainly not implementing iframes in posts.

    I know the browser support isn't that great, that is why I suggested the iframe shim (or use some other shim, but iframes really are the best way). I wasn't suggesting that you allow full use of iframes, but merely use their sandboxing features to implement cross-browser scoped CSS. If BBCode rendered as HTML is safe from injecting arbitrary JavaScript and/or HTML, then rendered BBCode inside an iframe is no less safe, provided you do not allow users to control their attributes like src.
     
    Back
    Top