Comments on: The scoped attribute https://stevefaulkner.github.io/html5doctored/the-scoped-attribute/ helping you implement HTML5 today Wed, 04 May 2016 10:02:12 +0000 hourly 1 By: Evert https://stevefaulkner.github.io/html5doctored/the-scoped-attribute/#comment-2095489 Wed, 24 Feb 2016 23:27:01 +0000 http://html5doctor.com/?p=3634#comment-2095489 Forgot: And older browsers will ignore this script-element as they do not understand the src-attribute on it.

]]>
By: Evert https://stevefaulkner.github.io/html5doctored/the-scoped-attribute/#comment-2095487 Wed, 24 Feb 2016 23:24:36 +0000 http://html5doctor.com/?p=3634#comment-2095487 I guess this ‘scoped’ business was introduced with web components in mind (styles inside a template are supposed to be scoped).
But I don’t like the idea one bit. (I don’t like the idea about web components. The basic thought behind it is great, but the implementation is horrible imho).

Anyway, I never understood why stylesheets are loaded using a link-element. So in order to prevent overused inline styles as well as promote backward compatibility, why not implement:

<style src='url' scoped='id-of-element' exclude-root=true|false>

This way you can target a specific part of the html through the scoped-attribute and with the exclude-root-attribute you can exclude these styles from other parts of the page.

]]>
By: Carl https://stevefaulkner.github.io/html5doctored/the-scoped-attribute/#comment-281499 Mon, 25 Aug 2014 21:39:03 +0000 http://html5doctor.com/?p=3634#comment-281499 Why not do it via CSS and use something similar to @media like @this or @scoped, or if it needs to be in the style tag use media=’scoped’ rather than blank or media=’all’. That should make it un-rendered by older browsers and newer browsers can make things pretty as needed!

Or maybe treat it like the Shadow DOM? If you really need to style something that much that can’t be done with a few extra classes or IDs then that might be a better way to achieve an isolated block of styled HTML. Kinda like a iFrame but more integrated.

]]>
By: Rasael https://stevefaulkner.github.io/html5doctored/the-scoped-attribute/#comment-202125 Thu, 07 Aug 2014 08:51:56 +0000 http://html5doctor.com/?p=3634#comment-202125 Probably in a production environment is not the best choice to go, especially for the compatibility issues but there are many use cases that made this attribute really useful!

In the project I’m working on there is almost 1MB of css that is generated and managed by an external company.

Therefore using the scoped attribute allows us to fix layout errors directly and propose a solution before the next release of the css. Without this element we should learn all css classes or have to wait for an answer and implementation and it could take days..

Therefore I’m in with this attribute, even better if its brought to a custom tag as Lazaris proposed and then, if used in the right way, it could only give benefits.

]]>
By: Edwin https://stevefaulkner.github.io/html5doctored/the-scoped-attribute/#comment-67454 Mon, 23 Jun 2014 14:37:43 +0000 http://html5doctor.com/?p=3634#comment-67454 And, it’s gone from the “blink” codebase:

http://src.chromium.org/viewvc/blink?view=revision&revision=175720

]]>
By: Fadly Indrawijaya https://stevefaulkner.github.io/html5doctored/the-scoped-attribute/#comment-49325 Sun, 11 May 2014 18:01:45 +0000 http://html5doctor.com/?p=3634#comment-49325 I think it’s great though was a mess when css mingle so much in html :)

]]>
By: Jason https://stevefaulkner.github.io/html5doctored/the-scoped-attribute/#comment-48583 Mon, 03 Mar 2014 19:54:14 +0000 http://html5doctor.com/?p=3634#comment-48583 I also don’t believe any sane web developer should use this unless they are are only interested in experimentation. The scope attribute is not crossbrowser compatible so if you use for example WordPresses Revolution Slider you run into the major problem of having a broken slider for different browsers at different resolutions. I think I would rather take the error from W3C than add the scoped attribute.

]]>
By: Jason https://stevefaulkner.github.io/html5doctored/the-scoped-attribute/#comment-48582 Mon, 03 Mar 2014 19:49:59 +0000 http://html5doctor.com/?p=3634#comment-48582 In my opinion I believe this started to come about people people are so used to writing JavaScript files inline while not using ‘inline’ but instead wanted styles to be pretty on multiple lines. If you think that inline styles are bad this would be just as bad.

In terms of specificity does this render itself with the same precedence as a typical inline style? Couldn’t you just write your styles to a php specific CSS file by reading the file and writing to it?

]]>
By: Ken Newman https://stevefaulkner.github.io/html5doctored/the-scoped-attribute/#comment-48504 Tue, 25 Feb 2014 22:13:03 +0000 http://html5doctor.com/?p=3634#comment-48504 I don’t much care for dogma surrounding the separations of concerns. As a general rule, in most cases, you should keep stuff separated…unless there is a compelling case not to. I encounter many such cases during my work, and think that putting styles inline, or embedded, are completely valid (doing so is only a problem when it’s ill-considered). It’s absurd to suggest that it never right to do so, or that it’s only an “edge case.” The scoped attribute is a brilliant feature. Syndicated content (article elements) and widgets seem obvious cases for it. When you “scope” with an id attr, you open it up for potential conflict.

]]>
By: Brendon Boshell https://stevefaulkner.github.io/html5doctored/the-scoped-attribute/#comment-37094 Thu, 01 Aug 2013 17:41:07 +0000 http://html5doctor.com/?p=3634#comment-37094 Would it not be wiser to have <style> scoped by default? I can only see this being relevant for adding third party code to your page, and it would be useful if that was constrained to a scope in that case. Although I don’t like the idea of mixing presentation and content, it seems more useful to have a “global” attribute instead — so you can use <style global> if you really wanted it for some reason. It would also be more backwards-compatible.

]]>