em An introduction to CSS pseudo-element hacks By nicolasgallagher.com Published On :: Thu, 13 Oct 2011 17:00:00 -0700 CSS is a versatile style language that is most frequently used to control the look and formatting of an HTML document based on information in the document tree. But there are some common publishing effects – such as formatting the first line of a paragraph – that would not be possible if you were only able to style elements based on this information. Fortunately, CSS has pseudo-elements and pseudo-classes. As their names imply, they are not part of the DOM in the way that ‘real’ HTML elements and classes are. Instead, they are CSS abstractions that provide additional, and otherwise inaccessible, information about the document. This article will discuss the CSS pseudo-elements that are part of CSS 2.1 – :first-letter, :first-line, :before, and :after – and how the :before and :after pseudo-elements can be exploited to create some interesting effects, without compromising the simplicity of your HTML. But first, let’s look at each type of pseudo-element and how to use them in their basic form. The :first-line and :first-letter pseudo-elements The :first-line pseudo-element lets you apply styles to the first formatted line of a block container element (i.e., elements with their display property set to block, inline-block, list-item, table-caption, or table-cell). For example: p:first-line { font-weight: bold; } …will change the first line of every paragraph to bold. The :first-line pseudo-element can be treated as if it were an extra HTML inline element wrapping only the first line of text in the paragraph. The :first-letter pseudo-element lets you apply styles to the first letter (and any preceding punctuation) of the first formatted line of a block container element. No other inline content (e.g. an image) can appear before the text. For example: p:first-letter { float: left; font-size: 200%; } …will produce a basic ‘drop cap’ effect. The first letter of every paragraph will be floated left, and twice as large as the other letters in the paragraph. The :first-letter pseudo-element can be treated as if it were an extra HTML inline element wrapping only the first letter of text in the paragraph. The :first-line and :first-letter pseudo-elements can only be attached to block container elements, but the first formatted line can be contained within any block-level descendant (e.g., elements with their display property set to block or list-item) in the same flow (i.e., not floated or positioned). For example, the following HTML fragment and CSS: <div><p>An example of the first line of text being within a descendant element</p></div> div:first-line { font-weight: bold; } …would still result in a bold first line of text, because the paragraph’s text is the first formatted line of the div. The :before and :after pseudo-elements The :before and :after pseudo-elements are used to insert generated content before or after an element’s content. They can be treated as if they were extra HTML inline elements inserted just before and after the content of their associated element. Generated content is specified using the content property which, in CSS 2.1, can only be used in conjunction with the :before and :after pseudo-elements. Furthermore, you must declare the content property in order to generate the :before and :after pseudo-elements. The content property can take string, url(), attr(), counter() and counters() values. The url() value is used to insert an image. The attr() function returns as a string the value of the specified attribute for the associated element. The counter() and counters() functions can be used to display the value of any CSS counters. For example, the following HTML fragment and CSS: <a href="http://wikipedia.org">Wikipedia</a> a:after { content: " (" attr(href) ")"; } …would display the value of the href attribute after a link’s content, resulting in the following anchor text for the example above: Wikipedia (http://wikipedia.org). This can be a helpful way to display the destination of specific links in printed web documents. Keep in mind that CSS is meant for adding presentation and not content. Therefore, the content property should be used with caution. It’s also worth noting that the :first-letter and :first-line pseudo-elements apply to the first letter and first line of an element including any generated content inserted using the :before and :after pseudo-elements. Browser support for pseudo-elements The :first-letter and :first-line pseudo-elements were introduced in CSS1 and there is wide basic support for them. However, IE 6 and IE 7 have particularly buggy implementations; even modern browsers are not entirely consistent in the way that they handle the :first-line and :first-letter pseudo-elements (example bugs). The :before and :after pseudo-elements were introduced in the CSS 2.1 specification and are fully implemented in Firefox 3.5+, IE 8+, Safari 3+, Google Chrome, and Opera. Modern versions of Firefox even support CSS transitions and animations applied to pseudo-elements. However, legacy browsers like IE 6 and IE 7 do not support the :before and :after pseudo-elements at all. For more detailed information on pseudo-element browser support, browser bugs, and workarounds, have a look at Sitepoint’s reference and this article on IE 6/7 issues. In most cases, the :before and :after pseudo-elements can be used as part of a ‘progressive enhancement’ approach to design and development, because IE 6 and IE 7 will simply ignore them altogether. Alternatively, Modernizr now includes a robust feature test for generated content, providing one way to specify fallbacks or enhancements depending on browser support. The important thing is to remember to check what happens in browsers where support is missing. Alternative ways to use pseudo-elements Let’s take a look at how the :before and :after pseudo-elements can be used as the basis for some interesting effects. Most of the time, this involves generating empty :before and :after pseudo-elements by declaring an empty string as the value of the content property. They can then be manipulated as if they were empty inline HTML elements, keeping your HTML clean and giving you full control of certain effects from within CSS style sheets. Simple visual enhancements, like speech bubbles and folded corners, can even be created without the need for images. This relies on the fact that you can create simple shapes using CSS. Several types of ‘CSS polygons’ can be created as a result of browsers rendering borders at an angle when they meet. This can be exploited to create triangles. For example, the following HTML fragment and CSS: <div class="triangle"></div> .triangle { width: 0; height: 0; border-width: 20px; border-style: solid; border-color: red transparent transparent; } …will create a downward pointing, red triangle. By varying the width, height, border-width, border-style, and border-color values you can produce different shapes and control their orientation and colour. For more information, be sure to read Jon Rogan’s summary of the technique. The more advanced pseudo-element hacks use the extra background canvas afforded by each :before and :after pseudo-element. This can help you crop background images, control the opacity of background images, and ‘fake’ multiple backgrounds and borders in browsers without support for CSS3 multiple backgrounds (e.g., IE 8). Taken to ludicrous extremes, you can even build a whole CSS icon set. To start with, let’s look at some simple effects that can be created without images or presentational HTML. Creating CSS speech bubbles In this example, a quote is styled to look like a speech bubble, using CSS. This is done by creating a triangle using a pseudo-element, and then absolutely positioning it in the desired place. By adding position:relative to the CSS styles for the HTML element, you can absolutely position the :after pseudo-element relative to its associated element. <div class="quote">[Quoted text]</div> .quote { position: relative; width: 300px; padding: 15px 25px 20px; margin: 20px auto; font: italic 26px/1.4 Georgia, serif; color: #fff; background: #245991; } .quote:after { content: ""; position: absolute; top: 100%; right: 25px; border-width: 30px 30px 0 0; border-style: solid; border-color: #245991 transparent; } There’s nothing stopping you from adding some CSS3 to further enhance the effect for capable browsers. This could be adding rounded corners to the box or applying a skew transform to the triangle itself. Fiddle with the code in this example. Creating CSS ‘ribbons’ Using the same principle, you can create a CSS ribbon effect without images or extra HTML. This time the effect uses 2 pseudo-element triangles. The HTML fragment is still very simple. <div class="container"> <h1>Simple CSS ribbon</h1> <p>[other content]</p> </div> You then need to use negative margins to pull the h1 outwards so that it extends over the padding and beyond the boundaries of the container div. The HTML fragment above can be styled using the following CSS: .container { width: 400px; padding: 20px; margin: 20px auto; background: #fff; } .container h1 { position: relative; padding: 10px 30px; margin: 0 -30px 20px; font-size: 20px; line-height: 24px; font-weight: bold; color: #fff; background: #87A800; } From here, you only need to add the pseudo-element triangles to create the ‘wrapping’ appearance associated with ribbons. The :before and :after pseudo-elements share many styles, so you can simplify the code by only overriding the styles that differ between the two. In this case, the triangle created with the :after pseudo-element must appear on the opposite side of the heading, and will be a mirror image of the other triangle. So you need to override the shared styles that control its position and orientation. .container h1:before, .container h1:after { content: ""; position: absolute; top: 100%; left: 0; border-width: 0 10px 10px 0; border-style: solid; border-color: transparent #647D01; } /* override shared styles */ .container h1:after { left: auto; right: 0; border-width: 0 0 10px 10px; } Fiddle with the code in this example. Creating CSS folded corners The final example of this form of pseudo-element hack creates a simple CSS folded-corner effect. A pseudo-element’s border properties are set to produce two differently-coloured touching triangles. One triangle is a slightly darker or lighter shade of the box’s background colour. The other triangle matches the background colour of the box’s parent (e.g. white). The pseudo-element is then positioned in the top right corner of its associated element to complete the effect. .note { position: relative; padding: 20px; margin: 2em 0; color: #fff; background: #97C02F; } .note:before { content: ""; position: absolute; top: 0; right: 0; border-width: 0 16px 16px 0; border-style: solid; border-color: #658E15 #fff; } Varying the size of the borders will vary the size and angle of the folded-corner. Fiddle with the code in this example. Pseudo background-crop Although creating polygons with pseudo-elements can produce some popular effects without images, the possibilities are inherently limited. But this is only one type of :before and :after pseudo-element hack. Treated as extra background canvases, they can be used to fill some gaps in existing browser support for CSS features. One of those features is the cropping of background images. In the future, it’s likely that you’ll be able to crop background images using fragment identifiers, as is proposed in the CSS Image Values Module Level 3 draft. But at the moment no browsers support the use of fragment identifiers with bitmap images. Until they do, you can make use of this CSS 2.1 hack to emulate background image cropping in modern browsers. The principle behind a ‘pseudo background-crop‘ is to apply a background-image to a pseudo-element rather than directly to an element in the HTML document. One of the applications of this technique is to crop icons that are part of a sprite. For example, a web app might allow users to ‘save’, ‘edit’, or ‘delete’ an item. The HTML involved might look something like this: <ul class="actions"> <li class="save"><a href="#">Save</a></li> <li class="edit"><a href="#">Edit</a></li> <li class="delete"><a href="#">Delete</a></li> </ul> To enhance the appearance of these ‘action’ links, it is common to see icons sitting alongside the anchor text. For argument’s sake, let’s say that the relevant icons are part of a sprite that is organised using a 16px × 16px grid. The :before pseudo-element – with dimensions that match the sprite’s grid unit – can be used to crop and display each icon. The sprite is referenced as a background image and the background-position property is used to control the precise positioning of each icon to be shown. .actions a:before { content: ""; float: left; width: 16px; height: 16px; margin: 0 5px 0 0; background: url(sprite.png); } .save a:before { background-position: 0 0; } .edit a:before { background-position: -16px 0; } .delete a:before { background-position: -32px 0; } Using pseudo-elements like this helps to avoid the need to either add liberal amounts of white space to sprites or use empty HTML elements to do the cropping. Fiddle with the code in this example. Pseudo background-position The CSS 2.1 specification limits the values of background-position to horizontal and vertical offsets from the top-left corner of an element. The CSS Backgrounds and Borders Module Level 3 working draft includes an improvement to the background-position property to allow offsets to be set from any side. However, Opera 11+ is currently the only browser to have implemented it. But by using pseudo-elements, it’s possible to emulate positioning a background image from any side in any browser with adequate CSS 2.1 support –’pseudo background-position‘. Once a pseudo-element is created, it must be absolutely positioned in front of the associated element’s background but behind its content, so as not to prevent users from being able to select text or click on links. This is done by setting a positive z-index on the element and a negative z-index on the pseudo-element. #content { position: relative; z-index: 1; } #content:before { content: ""; position: absolute; z-index: -1; } Now the pseudo-element can be sized and positioned to sit over any area within (or beyond) the element itself, without affecting its content. This is achieved by using any combination of values for the top, right, bottom, and left positional offsets, as well as the width, and height properties. It is the key to their flexibility. In this example, a 200px × 300px background image is applied to the pseudo-element, which is also given dimensions that match those of the image. Since the pseudo-element is absolutely positioned, it can be offset from the bottom and right of the associated HTML element. #content { position: relative; z-index: 1; } #content:before { content: ""; position: absolute; z-index: -1; bottom: 10px; right: 10px; width: 200px; height: 300px; background: url(image.jpg); } Many other hacks and effects are possible using the :before and :after pseudo-elements, especially when combined with CSS3. Hopefully this introduction to pseudo-elements, and how they can be exploited, will have inspired you to experiment with them in your work. The future of pseudo-elements The way that pseudo-elements are used will continue to change as CSS does. Some new applications will emerge, and existing ones will fade away as browser implementation of ‘CSS3 modules’ continues to improve. Generated content and pseudo-elements themselves are likely to undergo changes too. The CSS3 Generated and Replaced Content Module introduced a two-colon format for pseudo-elements (i.e., ::before) to help distinguish between pseudo-classes and pseudo-elements. But for compatibility with previous levels of CSS, pseudo-elements do not require two colons. Most modern browsers support both formats, but it is not supported by IE 8 and the single-colon format ensures greater backwards compatibility. The proposed extensions to pseudo-elements included the addition of nested pseudo-elements (::before::before), multiple pseudo-elements (::after(2)), wrapping pseudo-elements (::outside), and the ability to insert pseudo-elements into later parts of the document (::alternate). However, the CSS3 Generated and Replaced Content Module is undergoing significant changes. This article was originally published in .net magazine in April 2011 Related resources Interactive examples of the code throughout this article CSS generated content techniques Automatic numbering with CSS counters CSS image replacement using pseudo-elements Multiple backgrounds and borders with CSS 2.1 CSS background image hacks A whole bunch of amazing stuff pseudo-elements can do Full Article
em Another CSS image replacement technique By nicolasgallagher.com Published On :: Mon, 05 Mar 2012 16:00:00 -0800 A new image replacement technique was recently added to the HTML5 Boilerplate project. This post explains how it works and how it compares to alternative image replacement techniques. [15 December 2012] This technique is no longer used in HTML5 Boilerplate. It’s been replaced by another, more reliable approach. Here’s the CSS behind the recent update to the image replacement helper class in HTML5 Boilerplate. It has also made its way into the Compass framework. .ir { font: 0/0 a; text-shadow: none; color: transparent; } What does each declaration do? font:0/0 a – a shorthand property that zeros out the font size and line-height. The a value acts as a very short font-family (an idea taken from the BEM implementation of this method). The CSS validator complains that using 0/0 in the shorthand font property is not valid, but every browser accepts it and this appears to be an error in the validator. Using font:0px/0 a passes validation but it displayed as font:0/0 a in the code that the validator flags as valid. text-shadow:none – makes sure that any inherited text shadow is removed for the text. This prevents the chance of any text shadow colors showing over the background. color:transparent – needed for browsers than don’t completely crush the text to the point of being invisible. Safari 4 (extremely rare) is an example of such a browser. There may also be mobile browsers than require this declaration. IE6/7/8 don’t recognise this value for color, but fortunately IE7/8 don’t show any trace of the text. IE6 shows a faint trace. In the HTML5 Boilerplate image replacement helper, we’ve also removed any border and background-color that may be on the element. This makes it easier to use the helper class on elements like button or with links that may included background or border properties as part of a design decision. Benefits over text-indent methods The new technique avoids various problems with any text-indent method, including the one proposed by Scott Kellum to avoid iPad 1 performance problems related to large negative text indents. Works in IE6/7 on inline-block elements. Techniques based on text indentation are basically “broken”, as shown by this test case: http://jsfiddle.net/necolas/QZvYa/show/ Doesn’t result in any offscreen box being created. The text-indent methods result in a box being drawn (sometimes offscreen) for any text that have been negatively or positively indented. It can sometimes cause performance problems but the font-based method sidesteps those concerns. No need to specify a text-alignment and hide the overflow since the text is crushed to take up no space. No need to hide br or make all fallback HTML display:inline to get around the constraints of using a text indentation. This method is not affected by those problems. Fewer styles are needed as a result of these improvements. Drawbacks No image replacement hack is perfect. Leaves a very small trace of the text in IE6. This approach means that you cannot use em units for margins on elements that make use of this image replacement code. This is because the font size is set to 0. Windows-Eyes has a bug that prevents the reading of text hidden using this method. There are no problems with all other screenreaders that have been tested. Thanks to @jkiss for providing these detailed results and to @wilto for confirming this technique works for JAWS 12 in IE 6/7/8 and Firefox 4/5/6. Like so many IR methods, it doesn’t work when CSS is loaded but images are not. Text may not be hidden if a visitor is using a user style sheet which has explicitly set important font-size declarations for the element type on which you have applied the IR class. It’s worth noting that the NIR image replacement technique avoids these drawbacks, but lacks support in IE6/7. Closing comments I’ve been using this technique without significant problems for nearly a year, ever since Jonathan Neal and I used it in a clearfix experiment. The BEM framework also makes use of it for their icon components. The core idea was even proposed back in 2003 but the browser quirks of the day may have prevented wider use. If you come across any problems with this technique, please report them at the HTML5 Boilerplate GitHub issue tracker and include a test case when appropriate. Translations Nouvelle méthode de remplacement de texte par une image Full Article
em About HTML semantics and front-end architecture By nicolasgallagher.com Published On :: Wed, 14 Mar 2012 17:00:00 -0700 A collection of thoughts, experiences, ideas that I like, and ideas that I have been experimenting with over the last year. It covers HTML semantics, components and approaches to front-end architecture, class naming patterns, and HTTP compression. About semantics Semantics is the study of the relationships between signs and symbols and what they represent. In linguistics, this is primarily the study of the meaning of signs (such as words, phrases, or sounds) in language. In the context of front-end web development, semantics are largely concerned with the agreed meaning of HTML elements, attributes, and attribute values (including extensions like Microdata). These agreed semantics, which are usually formalised in specifications, can be used to help programmes (and subsequently humans) better understand aspects of the information on a website. However, even after formalisation, the semantics of elements, attributes, and attribute values are subject to adaptation and co-option by developers. This can lead to subsequent modifications of the formally agreed semantics (and is an HTML design principle). Distinguishing between different types of HTML semantics The principle of writing “semantic HTML” is one of the foundations of modern, professional front-end development. Most semantics are related to aspects of the nature of the existing or expected content (e.g. h1 element, lang attribute, email value of the type attribute, Microdata). However, not all semantics need to be content-derived. Class names cannot be “unsemantic”. Whatever names are being used: they have meaning, they have purpose. Class name semantics can be different to those of HTML elements. We can leverage the agreed “global” semantics of HTML elements, certain HTML attributes, Microdata, etc., without confusing their purpose with those of the “local” website/application-specific semantics that are usually contained in the values of attributes like the class attribute. Despite the HTML5 specification section on classes repeating the assumed “best practice” that… …authors are encouraged to use [class attribute] values that describe the nature of the content, rather than values that describe the desired presentation of the content. …there is no inherent reason to do this. In fact, it’s often a hindrance when working on large websites or applications. Content-layer semantics are already served by HTML elements and other attributes. Class names impart little or no useful semantic information to machines or human visitors unless it is part of a small set of agreed upon (and machine readable) names – Microformats. The primary purpose of a class name is to be a hook for CSS and JavaScript. If you don’t need to add presentation and behaviour to your web documents, then you probably don’t need classes in your HTML. Class names should communicate useful information to developers. It’s helpful to understand what a specific class name is going to do when you read a DOM snippet, especially in multi-developer teams where front-enders won’t be the only people working with HTML components. Take this very simple example: <div class="news"> <h2>News</h2> [news content] </div> The class name news doesn’t tell you anything that is not already obvious from the content. It gives you no information about the architectural structure of the component, and it cannot be used with content that isn’t “news”. Tying your class name semantics tightly to the nature of the content has already reduced the ability of your architecture to scale or be easily put to use by other developers. Content-independent class names An alternative is to derive class name semantics from repeating structural and functional patterns in a design. The most reusable components are those with class names that are independent of the content. We shouldn’t be afraid of making the connections between layers clear and explicit rather than having class names rigidly reflect specific content. Doing this doesn’t make classes “unsemantic”, it just means that their semantics are not derived from the content. We shouldn’t be afraid to include additional HTML elements if they help create more robust, flexible, and reusable components. Doing so does not make the HTML “unsemantic”, it just means that you use elements beyond the bare minimum needed to markup the content. Front-end architecture The aim of a component/template/object-oriented architecture is to be able to develop a limited number of reusable components that can contain a range of different content types. The important thing for class name semantics in non-trivial applications is that they be driven by pragmatism and best serve their primary purpose – providing meaningful, flexible, and reusable presentational/behavioural hooks for developers to use. Reusable and combinable components Scalable HTML/CSS must, by and large, rely on classes within the HTML to allow for the creation of reusable components. A flexible and reusable component is one which neither relies on existing within a certain part of the DOM tree, nor requires the use of specific element types. It should be able to adapt to different containers and be easily themed. If necessary, extra HTML elements (beyond those needed just to markup the content) and can be used to make the component more robust. A good example is what Nicole Sullivan calls the media object. Components that can be easily combined benefit from the avoidance of type selectors in favour of classes. The following example prevents the easy combination of the btn component with the uilist component. The problems are that the specificity of .btn is less than that of .uilist a (which will override any shared properties), and the uilist component requires anchors as child nodes. .btn { /* styles */ } .uilist { /* styles */ } .uilist a { /* styles */ } <nav class="uilist"> <a href="#">Home</a> <a href="#">About</a> <a class="btn" href="#">Login</a> </nav> An approach that improves the ease with which you can combine other components with uilist is to use classes to style the child DOM elements. Although this helps to reduce the specificity of the rule, the main benefit is that it gives you the option to apply the structural styles to any type of child node. .btn { /* styles */ } .uilist { /* styles */ } .uilist-item { /* styles */ } <nav class="uilist"> <a class="uilist-item" href="#">Home</a> <a class="uilist-item" href="#">About</a> <span class="uilist-item"> <a class="btn" href="#">Login</a> </span> </nav> JavaScript-specific classes Using some form of JavaScript-specific classes can help to reduce the risk that thematic or structural changes to components will break any JavaScript that is also applied. An approach that I’ve found helpful is to use certain classes only for JavaScript hooks – js-* – and not to hang any presentation off them. <a href="/login" class="btn btn-primary js-login"></a> This way, you can reduce the chance that changing the structure or theme of components will inadvertently affect any required JavaScript behaviour and complex functionality. Component modifiers Components often have variants with slightly different presentations from the base component, e.g., a different coloured background or border. There are two mains patterns used to create these component variants. I’m going to call them the “single-class” and “multi-class” patterns. The “single-class” pattern .btn, .btn-primary { /* button template styles */ } .btn-primary { /* styles specific to save button */ } <button class="btn">Default</button> <button class="btn-primary">Login</button> The “multi-class” pattern .btn { /* button template styles */ } .btn-primary { /* styles specific to primary button */ } <button class="btn">Default</button> <button class="btn btn-primary">Login</button> If you use a pre-processor, you might use Sass’s @extend functionality to reduce some of the maintenance work involved in using the “single-class” pattern. However, even with the help of a pre-processor, my preference is to use the “multi-class” pattern and add modifier classes in the HTML. I’ve found it to be a more scalable pattern. For example, take the base btn component and add a further 5 types of button and 3 additional sizes. Using a “multi-class” pattern you end up with 9 classes that can be mixed-and-matched. Using a “single-class” pattern you end up with 24 classes. It is also easier to make contextual tweaks to a component, if absolutely necessary. You might want to make small adjustments to any btn that appears within another component. /* "multi-class" adjustment */ .thing .btn { /* adjustments */ } /* "single-class" adjustment */ .thing .btn, .thing .btn-primary, .thing .btn-danger, .thing .btn-etc { /* adjustments */ } A “multi-class” pattern means you only need a single intra-component selector to target any type of btn-styled element within the component. A “single-class” pattern would mean that you may have to account for any possible button type, and adjust the selector whenever a new button variant is created. Structured class names When creating components – and “themes” that build upon them – some classes are used as component boundaries, some are used as component modifiers, and others are used to associate a collection of DOM nodes into a larger abstract presentational component. It’s hard to deduce the relationship between btn (component), btn-primary (modifier), btn-group (component), and btn-group-item (component sub-object) because the names don’t clearly surface the purpose of the class. There is no consistent pattern. In early 2011, I started experimenting with naming patterns that help me to more quickly understand the presentational relationship between nodes in a DOM snippet, rather than trying to piece together the site’s architecture by switching back-and-forth between HTML, CSS, and JS files. The notation in the gist is primarily influenced by the BEM system‘s approach to naming, but adapted into a form that I found easier to scan. Since I first wrote this post, several other teams and frameworks have adopted this approach. MontageJS modified the notation into a different style, which I prefer and currently use in the SUIT framework: /* Utility */ .u-utilityName {} /* Component */ .ComponentName {} /* Component modifier */ .ComponentName--modifierName {} /* Component descendant */ .ComponentName-descendant {} /* Component descendant modifier */ .ComponentName-descendant--modifierName {} /* Component state (scoped to component) */ .ComponentName.is-stateOfComponent {} This is merely a naming pattern that I’m finding helpful at the moment. It could take any form. But the benefit lies in removing the ambiguity of class names that rely only on (single) hyphens, or underscores, or camel case. A note on raw file size and HTTP compression Related to any discussion about modular/scalable CSS is a concern about file size and “bloat”. Nicole Sullivan’s talks often mention the file size savings (as well as maintenance improvements) that companies like Facebook experienced when adopting this kind of approach. Further to that, I thought I’d share my anecdotes about the effects of HTTP compression on pre-processor output and the extensive use of HTML classes. When Twitter Bootstrap first came out, I rewrote the compiled CSS to better reflect how I would author it by hand and to compare the file sizes. After minifying both files, the hand-crafted CSS was about 10% smaller than the pre-processor output. But when both files were also gzipped, the pre-processor output was about 5% smaller than the hand-crafted CSS. This highlights how important it is to compare the size of files after HTTP compression, because minified file sizes do not tell the whole story. It suggests that experienced CSS developers using pre-processors don’t need to be overly concerned about a certain degree of repetition in the compiled CSS because it can lend itself well to smaller file sizes after HTTP compression. The benefits of more maintainable “CSS” code via pre-processors should trump concerns about the aesthetics or size of the raw and minified output CSS. In another experiment, I removed every class attribute from a 60KB HTML file pulled from a live site (already made up of many reusable components). Doing this reduced the file size to 25KB. When the original and stripped files were gzipped, their sizes were 7.6KB and 6KB respectively – a difference of 1.6KB. The actual file size consequences of liberal class use are rarely going to be worth stressing over. How I learned to stop worrying… The experience of many skilled developers, over many years, has led to a shift in how large-scale website and applications are developed. Despite this, for individuals weaned on an ideology where “semantic HTML” means using content-derived class names (and even then, only as a last resort), it usually requires you to work on a large application before you can become acutely aware of the impractical nature of that approach. You have to be prepared to disgard old ideas, look at alternatives, and even revisit ways that you may have previously dismissed. Once you start writing non-trivial websites and applications that you and others must not only maintain but actively iterate upon, you quickly realise that despite your best efforts, your code starts to get harder and harder to maintain. It’s well worth taking the time to explore the work of some people who have proposed their own approaches to tackling these problems: Nicole’s blog and Object Oriented CSS project, Jonathan Snook’s Scalable Modular Architecture CSS, and the Block Element Modifier method that Yandex have developed. When you choose to author HTML and CSS in a way that seeks to reduce the amount of time you spend writing and editing CSS, it involves accepting that you must instead spend more time changing HTML classes on elements if you want to change their styles. This turns out to be fairly practical, both for front-end and back-end developers – anyone can rearrange pre-built “lego blocks”; it turns out that no one can perform CSS-alchemy. Full Article
em Coronavirus | Indore remains worst hit in Madhya Pradesh with 3 more deaths By www.thehindu.com Published On :: Sat, 09 May 2020 02:21:20 +0530 Bhopal, by comparison, has so far reported 679 cases and 24 deaths, with 354 patients, or more than half of those infected, having recovered. Full Article Other States
em AMU academic session from Aug. By www.thehindu.com Published On :: Fri, 08 May 2020 23:53:25 +0530 1,300 students of the varsity leave for home by special train Full Article Other States
em Air India employees move HC over pay cut By www.thehindu.com Published On :: Sat, 09 May 2020 01:51:00 +0530 They say it violates Centre’s directive Full Article Other States
em MASS condemn arrest of Gautam Navalakha and Anand Teltumbe By www.assamtimes.org Published On :: Thu, 16 Apr 2020 12:00:11 +0000 Full Article
em Stranded in the Nyiri Desert [electronic resource] : a group case study / Matthew J. Drake ; Aimee A. Kane and Mercy Shitemi By prospero.murdoch.edu.au Published On :: Drake, Matthew, author Full Article
em Strategic information management [electronic resource] : challenges and strategies in managing information systems / R.D. Galliers and D.E. Leidner By prospero.murdoch.edu.au Published On :: Galliers, Robert, 1947- Full Article
em A strategic-oriented implementation of projects [electronic resource] / Mihály Görög, PhD, Professor of Project Management By prospero.murdoch.edu.au Published On :: Görög, Mihály, 1951- Full Article
em Strategic risk management [electronic resource] : new tools for competitive advantage in an uncertain age / Paul C. Godfrey, [and three others] By prospero.murdoch.edu.au Published On :: Godfrey, Paul C., author Full Article
em Strategic value management [electronic resource] : stock value creation and the management of the firm / Juan Pablo Stegmann By prospero.murdoch.edu.au Published On :: Stegmann, Juan Pablo Full Article
em Strategisches IT-Management [electronic resource] / Josephine Hofmann, Matthias Knoll (Hrsg.) By prospero.murdoch.edu.au Published On :: Full Article
em Strategisches management für KMU [electronic resource] : unternehmenswachstum durch (r)evolutionäre Unternehmensführung / Gerrit Hamann By prospero.murdoch.edu.au Published On :: Hamann, Gerrit, author Full Article
em Strategisches management und marketing [electronic resource] : markt- und wettbewerbsanalyse, strategische frühaufklärung, portfolio-management / Edgar Kreilkamp By prospero.murdoch.edu.au Published On :: Kreilkamp, Edgar Full Article
em Streamlining business requirements [electronic resource] : the XCellR8 approach / Gerrie Caudle By prospero.murdoch.edu.au Published On :: Caudle, Gerrie Full Article
em Stressbewältigung, Empathie und Zufriedenheit in der Partnerschaft [electronic resource] / Bente Klein By prospero.murdoch.edu.au Published On :: Klein, Bente Full Article
em Succeeding in the project management jungle [electronic resource] : how to manage the people side of projects / Doug Russell By prospero.murdoch.edu.au Published On :: Russell, Doug Full Article
em Success in selling [electronic resource] : developing a world-class sales ecosystem / Reza Sisakhti By prospero.murdoch.edu.au Published On :: Sisakhti, Reza, author Full Article
em Successes and failures of knowledge management [electronic resource] / edited by Jay Liebowitz, Distinguished Chair of Applied Business and Finance, Harrisburg University of Science and Technology, Harrisburg, Pennsylvania By prospero.murdoch.edu.au Published On :: Full Article
em Successful management guidelines (collection) [electronic resource] / Martha I. Finney, Stephan Robbins By prospero.murdoch.edu.au Published On :: Finney, Martha I., author Full Article
em Successful project management [electronic resource] : how to complete projects on time, on budget, and on target / Michael S. Dobson By prospero.murdoch.edu.au Published On :: Dobson, Michael Singer, author Full Article
em Supply chain management [electronic resource] / Vinod V. Sople By prospero.murdoch.edu.au Published On :: Sople, Vinod V., author Full Article
em Supply chain management at warp speed [electronic resource] : integrating the system from end to end / Eli Schragenheim, H. William Dettmer, J. Wayne Patterson By prospero.murdoch.edu.au Published On :: Schragenheim, Eli Full Article
em Supply chain management for engineers [electronic resource] / Samuel H. Huang By prospero.murdoch.edu.au Published On :: Huang, Samuel H., author Full Article
em Supply chain management process standards [electronic resource] : deliver processes / Council of Supply Chain Management Professionals By prospero.murdoch.edu.au Published On :: Council of Supply Chain Management Professionals, author Full Article
em Supply chain management talent development [electronic resource] : acquire, develop, and advance processes / Council of Supply Chain Management Professionals By prospero.murdoch.edu.au Published On :: Council of Supply Chain Management Professionals, author Full Article
em Sustainability in supply chain management (collection) [electronic resource] / Peter A. Soyka, Robert Palevich, Steven M. Leon By prospero.murdoch.edu.au Published On :: Soyka, Peter A., 1958- author Full Article
em System center 2012 R2 configuration manager [electronic resource] : supplement to system center 2012 configuration manager (SCCM) unleashed / Kerrie Meyler, Jason Sandys, Greg Ramsey By prospero.murdoch.edu.au Published On :: Meyler, Kerrie, author Full Article
em System center operations manager 2007 R2 unleashed [electronic resource] : supplement to System center operations manager 2007 unleashed / Kerrie Meyler ... [et al.] By prospero.murdoch.edu.au Published On :: Full Article
em Systemisk projektledelse [electronic resource] / Henrik Schelde Andersen og Katrine Raae Søndergaard (red.) By prospero.murdoch.edu.au Published On :: Full Article
em Testdaten und Testdatenmanagement [electronic resource] : Vorgehen, Methoden und Praxis / Janet Albrecht-Zölch By prospero.murdoch.edu.au Published On :: Albrecht-Zölch, Janet, author Full Article
em Thinkers 50 business thought leaders from India [electronic resource] : the best ideas on innovation, management, strategy, and leadership / Stuart Crainer + Des Dearlove By prospero.murdoch.edu.au Published On :: Crainer, Stuart Full Article
em Thinkers 50 management [electronic resource] : cutting edge thinking to engage and motivate your employees for success / Stuart Crainer + Des Dearlove By prospero.murdoch.edu.au Published On :: Crainer, Stuart Full Article
em Thriving under stress [electronic resource] : harnessing demands in the workplace / Thomas W. Britt, Ph.D., Professor of Psychology, Clemson University, Steve M. Jex, Ph.D., Professor of Psychology, Bowling Green State University By prospero.murdoch.edu.au Published On :: Britt, Thomas W., 1966- Full Article
em Time management in an instant [electronic resource] : 60 ways to make the most of your day / Karen Leland & Keith Bailey By prospero.murdoch.edu.au Published On :: Leland, Karen Full Article
em Comment tirer profit de l'intelligence collective? [electronic resource] : pratiques de management et dynamiques d'équipe / par Véronique Bronckart By prospero.murdoch.edu.au Published On :: Bronckart, Véronique, author Full Article
em Too good to fail? [electronic resource] : how management gets it wrong and how you can get it right / Jan Filochowski By prospero.murdoch.edu.au Published On :: Filochowski, Jan Full Article
em The top 50 management dilemmas [electronic resource] : fast solutions to everyday challenges / Sona Sherratt and Roger Delves By prospero.murdoch.edu.au Published On :: Sherratt, Sona Full Article
em Total quality management [electronic resource] / Poornima M. Charantimath By prospero.murdoch.edu.au Published On :: Charantimath, Poornima M., author Full Article
em Total quality management and just-in-time purchasing [electronic resource] : their effects on performance of firms operating in the U.S. / Hale Kaynak By prospero.murdoch.edu.au Published On :: Kaynak, Hale, 1956- Full Article
em Total Quality Management [electronic resource] : Key Concepts and Case Studies / D.R. Kiran By prospero.murdoch.edu.au Published On :: Kiran, D. R., author Full Article
em Total quality of management [electronic resource] / Tapan K. Bose By prospero.murdoch.edu.au Published On :: Bose, Tapan K., author Full Article
em Toyota China [electronic resource] : matching supply with demand / Chuck Munson with Xiaoying Liang, Lijun Ma, and Houmin Yan By prospero.murdoch.edu.au Published On :: Munson, Chuck, author Full Article
em The triple constraints in project management [electronic resource] / Michael S. Dobson By prospero.murdoch.edu.au Published On :: Dobson, Michael Singer, author Full Article
em Troubleshooting system center configuration manager [electronic resource] : troubleshoot all the aspects of your Configuration Manager installation, from basic easy checks to the advanced log files and serious issues / Peter Egerton, Gerry Hampson By prospero.murdoch.edu.au Published On :: Egerton, Peter, author Full Article
em The truth about motivating your employees [electronic resource] : the essential truths in 20 minutes / Martha I. Finney By prospero.murdoch.edu.au Published On :: Finney, Martha I., author Full Article
em Turn enemies into allies [electronic resource] : the art of peace in the workplace / Judy Ringer ; foreword by James Warda ; illustrations by Adam Richardson By prospero.murdoch.edu.au Published On :: Ringer, Judy, 1949- author Full Article
em Journal of service management research (Online) By prospero.murdoch.edu.au Published On :: Full Article