Comprehensive List of Browser-Specific CSS Hacks

/***** Selector Hacks ******/
 
/* IE6 and below */
* html #uno  { color: red }
 
/* IE7 */
*:first-child+html #dos { color: red } 
 
/* IE7, FF, Saf, Opera  */
html>body #tres { color: red }
 
/* IE8, FF, Saf, Opera (Everything but IE 6,7) */
html>/**/body #cuatro { color: red }
 
/* Opera 9.27 and below, safari 2 */
html:first-child #cinco { color: red }
 
/* Safari 2-3 */
html[xmlns*=""] body:last-child #seis { color: red }
 
/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:nth-of-type(1) #siete { color: red }
 
/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:first-of-type #ocho {  color: red }
 
/* saf3+, chrome1+ */
@media screen and (-webkit-min-device-pixel-ratio:0) {
 #diez  { color: red  }
}
 
/* iPhone / mobile webkit */
@media screen and (max-device-width: 480px) {
 #veintiseis { color: red  }
}
 
 
/* Safari 2 - 3.1 */
html[xmlns*=""]:root #trece  { color: red  }
 
/* Safari 2 - 3.1, Opera 9.25 */
*|html[xmlns*=""] #catorce { color: red  }
 
/* Everything but IE6-8 */
:root *> #quince { color: red  }
 
/* IE7 */
*+html #dieciocho {  color: red }
 
/* Firefox only. 1+ */
#veinticuatro,  x:-moz-any-link  { color: red }
 
/* Firefox 3.0+ */
#veinticinco,  x:-moz-any-link, x:default  { color: red  }
 
/* FF 3.5+ */
body:not(:-moz-handler-blocked) #cuarenta { color: red; }
 
 
/***** Attribute Hacks ******/
 
/* IE6 */
#once { _color: blue }
 
/* IE6, IE7 */
#doce { *color: blue; /* or #color: blue */ }
 
/* Everything but IE6 */
#diecisiete { color/**/: blue }
 
/* IE6, IE7, IE8, but also IE9 in some cases :( */
#diecinueve { color: blue\9; }
 
/* IE7, IE8 */
#veinte { color/*\**/: blue\9; }
 
/* IE6, IE7 -- acts as an !important */
#veintesiete { color: blue !ie; } /* string after ! can be anything */
 
/* IE8, IE9 */
#anotherone  {color: blue/;} /* must go at the END of all rules */

Trang điểm mắt tông xanh

Trang điểm mắt tông xanh

Giới thiệu cả nhà cách trang điểm mắt tông xanh nhé

Đôi mắt được trang điểm đúng cách với màu xanh lá sẽ vô cùng thu hút bởi vẻ cá tính, sắc sảo và quý phái.

Bước 1: Để kiểu trang điểm được hoàn hảo, bạn không thể quên làm sạch da trước khi makeup, sau đó dùng kem nền dạng lỏng tản một lớp thật mỏng lên gương mặt.

Bước 2: Dùng phấn phủ dặm khắp gương mặt.

Bước 3: Khi trang điểm mắt, ta sẽ sử dụng 3 tông màu chính là xanh lá nhạt (1), ghi (2), xanh lá đậm (3).

Bước 4: Dùng cọ mắt đầu tròn lần lượt đánh ba gam màu này lên bầu mắt theo hình minh hoạ.

Bước 5: Sử dụng bút nước kẻ mắt vẽ phác đường kẻ mắt, sau đó tô đầy đường kẻ mắt một cách cẩn thận.

Bước 6: Chải mascara cho cả hàng mi trên và dưới để mi cong thu hút hơn.

Bước 7: Cuối cùng, một chút sắc hồng cam cho má và môi, vậy là kiểu trang điểm với sắc xanh và cam đã thật hoàn hảo rồi!

Vứt bỏ anh là điều dũng cảm nhất

“Chúng ta từng yêu, từng sai, từng giãy giụa, từng chịu ấm ức, cũng từng tan nát cõi lòng, ngẩng cao đầu mắt nhỏ lệ, nhưng chúng ta chưa bao giờ hối hận”. Nếu yêu ai đó và muốn ở bên người ấy, bạn hãy thật kiên trì, và, cũng đừng bỏ qua cuốn sách này. Và, cũng đừng bỏ qua cuốn sách này nếu bạn yêu ai đó mà không thể ở bên họ. Bởi đơn giản, cuốn sách sẽ chỉ cho bạn học cách “cho” và “nhận”, học cách “nhớ” và quên”…

Thời trang dạo phố tinh tế của Trương Tử Lâm

Thời trang dạo phố tinh tế của Trương Tử Lâm

Không chỉ phát huy lợi thế chiều cao nổi trội và đôi chân dài miên man, Hoa hậu Thế giới 2007 còn rất khéo léo phối hợp màu sắc, phụ kiện để trở nên rạng rỡ, trẻ trung trong những trang phục xuống phố.
Trương Tử Lâm diện đầm đỏ dự tiệc ở Cannes

Trương Tử Lâm

Trương Tử Lâm (Zhang Zilin) trẻ trung và khỏe khoắn. Lối phối màu trang phục theo kiểu color block đang rất thịnh hành khiến cô gái 27 tuổi trẻ trung như mới vừa 20.

Trương Tử Lâm

Màu hồng tím chủ đạo, Tử Lâm xinh tươi và đằm thắm. Và không thể không kể đến sự tinh tế trong cách tạo sự tương đồng về màu sắc và kiểu dáng giữa chiếc áo và túi xách, giữa vòng cổ và vòng tay.

Trương Tử Lâm

Hoa hậu Thế giới đẹp mong manh và nổi bật trên phố.

Trương Tử Lâm

Vẻ đẹp tổng thể ở Trương Tử Lâm có được nhờ sự chăm chút từng chi tiết nhỏ trên trang phục.

Trương Tử Lâm

Trương Tử Lâm trẻ trung và khỏe khoắn. Đôi chân dài luôn là thứ được Tử Lâm khoe khéo trong mọi trang phục dạo phố.

Trương Tử Lâm

Hình ảnh này là một trong những minh chứng cho cái đẹp của sự giản dị.

Google đang phát triển dịch vụ cạnh tranh với Facebook

Facebook cùng với những Twitter, Myspace… đang là những mạng xã hội phổ biến và có số lượng người dùng đông đảo nhất hiện nay, tất nhiên Google không muốn bỏ qua thị trường mới mẻ nhưng cũng rất hứa hẹn này, bằng chứng cho thấy gã khổng lồ ngành tìm kiếm đang nung nấu một ý định cho ra mắt dịch vụ mạng xã hội của riêng mình nhằm cạnh tranh trực tiếp với Facebook. Thông tin này được chính cựu giám đốc cấp cao phụ trách công nghệ của Facebook, ngài Adam D’Angelo tiết lộ, ông cho biết dịch vụ của Google sẽ có tên Google Me và còn “cảnh báo” Facebook rằng Google đầu tư cho dự án này rất nhiều cũng như chuẩn bị rất kỹ lưỡng. Thông tin về Google Me đã từng xuất hiện nhưng chỉ là những tin đồn, giờ đây D’Angelo đã chính thức xác nhận dự án có thật này của Google. Google hiện cũng đang có một dịch vụ được coi là Facebook thu nhỏ mang tên Google Buzz nhưng nó quá đơn giản, họ cần một dịch vụ mạng xã hội đầy đủ chức năng, mạnh mẽ và có thể cạnh tranh với Facebook. Google có lợi thế là một đại gia, với những dịch vụ nền web có sẵn, liệu Google Me có đối trọng được với Facebook?

Nguon : http://www.tinhte.vn/tin-tuc-su-kien-10/google-dang-phat-trien-dich-vu-canh-tranh-voi-facebook-432578/

Drupal SEO Modules

There are a number of Drupal SEO modules to choose from. Here is a summary of the most popular ones to help with your Drupal search engine optimization.

Module Project Page Version Importance Tutorials
Path http://drupal.org/ handbook/modules/path 4/5/6 must have Path Tutorial
Path Auto http://drupal.org/ project/pathauto 5/6 must have Pathauto Tutorial
Pathauto Settings Tutorial
Page Title http://drupal.org/ project/page_title 5/6 must have
Global Redirect http://drupal.org/ project/globalredirect 4/5/6 must have Global Redirect Tutorial
Path Redirect http://drupal.org/ project/path_redirect 5/6/7 must have
Meta Tags (nodewords) http://drupal.org/ project/nodewords 5/6 must have Meta Tags (nodewords) Tutorial
Meta Tags by Path (nodewords bypath) http://drupal.org/ project/nodewords_bypath 5/6 good to have
Meta Tags Node Type (nodewords nodetype) http://drupal.org/ project/nodewords_nodetype 5/6 optional
XML Sitemap http://drupal.org/ project/xmlsitemap 5/6 good to have
Menu Attributes http://drupal.org/ project/menu_attributes 6 good to have Menu Attributes Nofollow Tutorial
Automatic Node titles http://drupal.org/ project/auto_nodetitle 4/5/6 good to have
Search 404 http://drupal.org/ project/search404 4/5/6 good to have
Links Checker http://drupal.org/ project/linkchecker 5/6 good to have Broken Links Tutorial
SEO Checklist http://drupal.org/ project/seo_checklist 5/6 good to have
SEO Friend http://drupal.org/ project/seo_friend 6 good to have SEO Friend Screenshots
HTML Purifier http://drupal.org/ project/htmlpurifier 5/6 good to have
Google Analytics http://drupal.org/ project/google_analytics 5/6
Service Links http://drupal.org/ project/service_links 5/6 optional Service Links Tutorial
Digg This http://drupal.org/ project/diggthis 5/6 optional
good to have
Nofollow List http://drupal.org/ project/nofollowlist 5/6
SEO Checker http://drupal.org/ project/seo_checker 6
Excerpt http://drupal.org/ project/excerpt 5/6
Alinks http://drupal.org/ project/alinks 5/6
More Like This http://drupal.org/ project/morelikethis 6
Related Content http://drupal.org/ project/relatedcontent 5/6
Glossify Internal Links Auto SEO http://drupal.org/ project/glossify 5/6
Calais http://drupal.org/ project/opencalais 6
Safe HTML http://drupal.org/ project/safehtml 4/5
Urlify http://drupal.org/ project/urlify 4/5
Find URL Alias http://drupal.org/ project/find_path 4/5
Related Links http://drupal.org/ project/relatedlinks 4/5
URL List http://drupal.org/ project/urllist 6
RobotsTxt http://drupal.org/ project/robotstxt 5/6
Page Title by Path http://drupal.org/ project/page_title_bypath 5
Custom Breadcrumbs http://drupal.org/ project/custom_breadcrumbs 5/6
Pathologic http://drupal.org/ project/pathologic 6

CSS Differences in Internet Explorer 6, 7 and 8

One of the most bizarre statistical facts in relation to browser use has to be the virtual widespread numbers that currently exist in the use of Internet Explorer versions 6, 7 and 8. As of this writing, Internet Explorer holds about a 65% market share combined across all their currently used browsers. In the web development community, this number is much lower, showing about a 40% share.

Ie in CSS Differences in Internet Explorer 6, 7 and 8

The interesting part of those statistics is that the numbers across IE6, IE7, and IE8 are very close, preventing a single Microsoft browser from dominating browser stats — contrary to what has been the trend in the past. Due to these unfortunate statistics, it is imperative that developers do thorough testing in all currently-used Internet Explorer browsers when working on websites for clients, and on personal projects that target a broader audience.

Thanks to the many available JavaScript libraries, JavaScript testing across different browsers has become as close to perfect as the current situation will allow. But this is not true in CSS development, particularly in relation to the three currently used versions of Internet Explorer.

This article will attempt to provide an exhaustive, easy-to-use reference for developers desiring to know the differences in CSS support for IE6, IE7 and IE8. This reference contains brief descriptions and compatibility for:

  • Any item that is supported by one of the three browser versions, but not the other two
  • Any item that is supported by two of the three browser versions, but not the other one
1 body>p {
2     color: #fff;
3 }
Description

The child selector selects all elements that are immediate children of a specified parent element. In the example above, body is the parent, and p is the child.

Support
IE6
No
IE7
Yes
IE8
Yes
Bugs

In IE7, the child selector will not work if there is an HTML comment between the parent item and the child.

Chained Classes

Example
Description

Chained classes are used when the same HTML element has multiple classes declared, like this:

<div class="class1 class2 class3">
<p>Content here.</p>
</div>
Support
IE6
No
IE7
Yes
IE8
Yes
Bugs

IE6 appears to support this property, because it matches the last class in the chain to an element having that class, however, it does not restrict the class to an element that has all the classes in the chain, like it should.

Attribute Selectors

Example
Description

This selector allows an element to be targeted only if it has the specified attribute. In the example above, all anchor tags that have href attributes would qualify, but not anchor tags that did not have href attributes.

Support
IE6
No
IE7
Yes
IE8
Yes

Adjacent Sibling Selectors

Example
Description

This selector targets siblings that are adjacent to the specified element. The example above would target all paragraph tags that are siblings of, and come directly after, primary heading tags. For example:

<h1>heading</h1>
<p>Content here.</p>
<p>Content here.</p>

In the code above, the CSS styles specified would target only the first paragraph, because it is a sibling to the <h1> tag and is adjacent. The second paragraph is a sibling, but is not adjacent.

Support
IE6
No
IE7
Yes
IE8
Yes
Bugs

In IE7, the adjacent sibling selector will not work if there is an HTML comment between the siblings.

General Sibling Selectors

Example
Description

This selector targets all siblings that appear after a specified element. Applying this selector to the HTML example given in the previous section will select both paragraph tags, however, if one of the paragraphs appeared before the heading, that paragraph would not be targeted.

Support
IE6
No
IE7
Yes
IE8
Yes

Pseudo-Classes and Pseudo-Elements

Descendant Selector After :hover Pseudo-Class

Example
Description

An element can be targeted with a selector after a :hover pseudo class, similar to how any descendant selector works. The above example would change the font color inside all <span> elements inside of anchor elements while the anchor is hovered over.

Support
IE6
No
IE7
Yes
IE8
Yes

Chained Pseudo-Classes

Example
Description

Pseudo-classes can be chained to narrow element selection. The above example would target every anchor tag that is the first child of its parent and apply a hover class to it.

Support
IE6
No
IE7
Yes
IE8
Yes

:hover on Non-Anchor Elements

Example
Description

The :hover pseudo-class can apply a hover, or rollover state, to any element, not just anchor tags.

Support
IE6
No
IE7
Yes
IE8
Yes

:first-child Pseudo-Class

Example
Description

This pseudo-class targets each specified element that is the first child of its parent.

Support
IE6
No
IE7
Yes
IE8
Yes
Bugs

In IE7, the first-child pseudo-class will not work if an HTML comment appears before the targeted first child element.

:focus Pseudo-Class

Example
Description

This pseudo-class targets any element that has keyboard focus.

Support
IE6
No
IE7
No
IE8
Yes

:before and :after Pseudo-Elements

Example
1 #box:before {
2     content: "This text is before the box";
3 }
4
5 #box:after {
6     content: "This text is after the box";
7 }
Description

This pseudo-element places generated content before or after the specified element, used in conjunction with the content property.

Support
IE6
No
IE7
No
IE8
Yes

Property Support

Virtual Dimensions Determined by Position

Example
1 #box {
2     position: absolute;
3     top: 0;
4     right: 100px;
5     left: 0;
6     bottom: 200px;
7     background: blue;
8 }
Description

Specifying top, right, bottom, and left values for an absolutely positioned element will give the element “virtual” dimensions (width and height), even if width and height are not specified.

Support
IE6
No
IE7
Yes
IE8
Yes

Min-Height & Min-Width

Example
Description

These properties specify minimum values for either height or width, allowing a box to be larger, but not smaller, than the specified minimum values. They can be used together or individually.

Support
IE6
No
IE7
Yes
IE8
Yes

Max-Height & Max-Width

Example
Description

These properties specify maximum values for either height or width, allowing a box to be smaller, but not larger, than the specified minimum values. They can be used together or individually.

Support
IE6
No
IE7
Yes
IE8
Yes

Transparent Border Color

Example
Description

A transparent border color allows a border to occupy the same space as would be occupied if the border was visible, or opaque.

Support
IE6
No
IE7
Yes
IE8
Yes

Fixed-Position Elements

Example
Description

This value for the position property allows an element to be positioned absolutely relative to the viewport.

Support
IE6
No
IE7
Yes
IE8
Yes

Fixed-Position Background Relative to Viewport

Example
1 #box {
2     background-image: url(images/bg.jpg);
3     background-position: 0 0;
4     background-attachment: fixed;
5 }
Description

A fixed value for the background-attachment property allows a background image to be positioned absolutely relative to the viewport.

Support
IE6
No
IE7
Yes
IE8
Yes
Bugs

IE6 incorrectly fixes the background image in relation to the containing parent of the element that has the background set, therefore this value only works in IE6 when its used on the root element.

Property Value “inherit”

Example
Description

Applying the value inherit to a property allows an element to inherit the computed value for that property from its containing element.

Support
IE6
No
IE7
No
IE8
Yes
Bugs

IE6 and IE7 do not support the value inherit except when applied to the direction and visibility properties.

Border Spacing on Table Cells

Example
Description

This property sets the spacing between the borders of adjacent table cells.

Support
IE6
No
IE7
No
IE8
Yes

Rendering of Empty Cells in Tables

Example
Description

This property, which only applies to elements that have their display property set to table-cell, allows empty cells to be rendered with their borders and backgrounds, or else hidden.

Support
IE6
No
IE7
No
IE8
Yes

Vertical Position of a Table Caption

Example
Description

This property allows a table caption to appear at the bottom of a table, instead of at the top, which is the default.

Support
IE6
No
IE7
No
IE8
Yes

Clipping Regions

Example
Description

This property specifies an area of a box that is visible, making the rest “clipped”, or invisible.

Support
IE6
No
IE7
No
IE8
Yes
Bugs

Interestingly, this property works in IE6 and IE7 if the deprecated comma-less syntax is used (i.e. whitespace between the clipping values instead of commas)

Orphaned and Widowed Text in Printed Pages

Example
Description

The orphans property specifies the minimum number of lines to display at the bottom of a printed page. The widows property specifies the minimum number of lines to display at the top of a printed page.

Support
IE6
No
IE7
No
IE8
Yes

Page Breaks Inside Boxes

Example
Description

This property specifies whether a page break should occur inside of a specified element or not.

Support
IE6
No
IE7
No
IE8
Yes

Outline Properties

Example
Description

outline is the shorthand property that encompasses outline-style, outline-width, and outline-color. This property is preferable to the border property since it does not affect document flow, thus better aiding debugging of layout issues.

Support
IE6
No
IE7
No
IE8
Yes

Alternative Values for the Display Property

Example
Description

The display property is usually set to block, inline, or none. Alternative values include:

  • inline-block
  • inline-table
  • list-item
  • run-in
  • table
  • table-caption
  • table-cell
  • table-column
  • table-column-group
  • table-footer-group
  • table-header-group
  • table-row
  • table-row-group
Support
IE6
No
IE7
No
IE8
Yes

Handling of Collapsible Whitespace

Example
1 p {
2     white-space: pre-line;
3 }
4
5 div {
6     white-space: pre-wrap;
7 }
Description

The pre-line value for the white-space property specifies that multiple whitespace elements collapse into a single space, while allowing explicitly set line breaks. The pre-wrap value for the white-space property specifies that multiple whitespace elements do not collapse into a single space, while allowing explicitly set line breaks.

Support
IE6
No
IE7
No
IE8
Yes

Other Miscellaneous Techniques

Media Types for @import

Example
Description

A media type for an imported style sheet is declared after the location of the style sheet, as in the example above. In this example, the media type is “screen”.

Support
IE6
No
IE7
No
IE8
Yes
Bugs

Although IE6 and IE7 support @import, they fail when a media type is specified, causing the entire @import rule to be ignored.

Incrementing of Counter Values

Example
1 h2 {
2     counter-increment: headers;
3 }
4
5 h2:before {
6     content: counter(headers) ". ";
7 }
Description

This CSS technique allows auto-incrementing numbers to appear before specified elements, and is used in conjunction with the before pseudo-element.

Support
IE6
No
IE7
No
IE8
Yes

Quote Characters for Generated Content

Example
01 q {
02     quotes: "'" "'";
03 }
04
05 q:before {
06     content: open-quote;
07 }
08
09 q:after {
10     content: close-quote;
11 }
Description

Specifies the quote characters to use for generated content applied to the q (quotation) tag.

Support
IE6
No
IE7
No
IE8
Yes

Significant Bugs and Incompatibilities

Following is a brief description of various bugs that occur in IE6 and IE7 that are not described or alluded to above. This list does not include items that lack support in all three browsers.

IE6 Bugs

  • Doesn’t support styling of the <abbr> element
  • Doesn’t support classes and IDs that begin with a hyphen or underscore
  • <select> elements always appear at the top of the stack, unaffected by z-index values
  • :hover pseudo-class values are ignored if anchor pseudo-classes are not in the correct order (:link, :visited, :hover)
  • An !important declaration on a property is overridden by a 2nd declaration of the same property in the same rule set that doesn’t use !important
  • height behaves like min-height
  • width behaves like min-width
  • Left and right margins are doubled on floated elements that touch their parents’ side edges
  • Dotted borders appear identical to dashed borders
  • line-through value for text-decoration property appears higher on the text than on other browsers
  • List items for an ordered list that have a layout will not increment their numbers, leaving all list items preceded by the number “1”
  • List items don’t support all possible values for list-style-type
  • List items with a specified list-style-image will not display the image if they are floated
  • Offers only partial support for @font-face
  • Some selectors will wrongly match comments and the doctype declaration
  • If an ID selector combined with a class selector is unmatched, the same ID selector combined with different class selectors will also be treated as unmatched

IE7 Bugs

  • List items for an ordered list that have a layout will not increment their numbers, leaving all list items preceded by the number “1”
  • List items don’t support all possible values for list-style-type
  • List items with a specified list-style-image will not display the image if they are floated
  • Offers only partial support for @font-face
  • Some selectors will wrongly match comments and the doctype declaration

Some IE bugs not mentioned here occur only under particular circumstances, and are not specific to one particular CSS property or value. See the references below for some of those additional issues.

Internet Explorer and the CSS box model

Internet Explorer and the CSS box model

One of the differences between Internet Explorer and standards compliant Web browsers that cause a lot of trouble for CSS beginners is the CSS box model. Since the box model is what browsers use to calculate an element’s total width and height, it is quite understandable that different browsers producing different results can be both confusing and frustrating.

How the CSS box model works has been explained by others many times already. Nonetheless I still see questions related to the CSS box model on forums and mailing lists, and frequently encounter sites that expect browsers to use Internet Explorer’s non-standard way of calculating box dimensions. That is why I have written this article, which to a large extent is a translation of an article I wrote for Swedish magazine CAP&Design earlier this year.

If you already know how the different box models work and how to handle Internet Explorer, there is nothing new for you here. If you get different box dimensions in IE and other browsers without knowing why, keep reading.

The CSS box model diagram

Here is a simple diagram showing how the dimensions of an element are related in CSS:

The Internet Explorer CSS box model includes padding and borders in the value assigned to the width property.

For the purposes of this article, all browsers handle the margin property the same way when calculating an element’s total width, so I’ll be concentrating on the padding and border properties.

The W3C Box model

First a look at the the W3C box model, which is used by all standards compliant browsers and by Internet Explorer 6 and later if the circumstances are right. In the W3C CSS box model a block level element’s total width is calculated using the following formula:

total width = margin-left + border-left + padding-left + width + padding-right + border-right + margin-right

The same concept applies to height, but for the sake of simplicity I will only talk about width from now on.

The IE Box model

The IE Box model is similar except for one important difference: paddings and borders are not included in the calculation:

total width = margin-left + width + margin-right

This means that if the element also has horizontal padding and/or borders, the actual content area will shrink to make room for them.

IE versions

Versions 5.5 and earlier of Internet Explorer for Windows always use the IE Box model. What many do not seem to be aware of is that IE 6 and later use the W3C box model when in standards compliant mode. This is a good thing since it means that problems will only occur in IE/Win 5.5 and older, provided that you use a DOCTYPE that makes IE use standards compliant mode.

Attacking the problem

By making sure that IE 6 is in standards compliant mode, you only have to care about this whole thing if you still are concerned about your sites looking the same in IE 5.*/Win as in more recent browsers. If that includes you there are several ways of attacking the problem, listed here in my order of preference:

  1. Avoid situations that cause problems
  2. Insert extra markup
  3. Use conditional comments
  4. Use CSS hacks

Since the problems caused by the Box model differences are often only cosmetic, my personal preference is to simply not bother with IE 5.*/Win. Sometimes that isn’t acceptable and I have to use one of the methods I’ll describe here.

1. Avoid situations that cause problems

This is how I prefer to solve the problem. I simply avoid specifying both width and padding or border for the same element. This ensures that all browsers will use the same total width, no matter which box model they use.

Let me use an example to illustrate. The HTML used to mark up a list of news articles could look like this (simplified):

  1. <div id="news">
  2. <h2>News</h2>
  3. <ul>
  4. <li>
  5. <h3>News article 1</h3>
  6. <p>Lorem ipsum dolor sit amet</p>
  7. </li>
  8. <li>
  9. <h3>News article 2</h3>
  10. <p>Lorem ipsum dolor sit amet</p>
  11. </li>
  12. </ul>
  13. </div>

To make the list 250 pixels wide with a one pixel border and 10 pixels of padding, you could use the following CSS:

  1. #news {
  2. padding:10px;
  3. border:1px solid;
  4. width:228px;
  5. }

In standards compliant browsers, the total width will be 250 pixels (1px left border + 10px left padding + width + 10px right padding + 1px right border). In IE 5.5 and earlier, the total width will be 228 pixels since it doesn’t add paddings and borders.

So how can you avoid this? Let’s assume that the news list is in another container, for instance a sidebar:

  1. <div id="sidebar">
  2. <div id="news">
  3. ...
  4. </div>
  5. </div>

If that is the case you can set the width on that container instead:

  1. #sidebar {width:250px}
  2. #news {
  3. padding:10px;
  4. border:1px solid;
  5. }

Since #news is a block level element it will automatically fill the entire width of its parent element, which in this case is #sidebar.

2. Insert extra markup

If you can’t use method 1, another method is to insert extra markup. Using the same example as previously, assume that #news is not supposed to expand to the full width of #sidebar. Specifying a width for #news to prevent that is a the scenario you want to avoid. A workaround is to change the markup to this:

  1. <div id="news">
  2. <div>
  3. <h2>News</h2>
  4. <ul>
  5. ...
  6. </ul>
  7. </div>
  8. </div>

and use the following CSS:

  1. #news {width:250px}
  2. #news div {
  3. padding:10px;
  4. border:1px solid;
  5. }

The outer element controls the width, and the inner element contains the border and padding.

It’s up to you to decide whether it is a reasonable compromise to add extra markup like this. It is obviously better if you can avoid doing so, but an extra div element doesn’t cause any other problems than increased file size and slightly reduced markup maintainability. It does not affect accessibility or how the document is presented with CSS off. Besides, having an extra element is necessary to create certain designs, so you may already have the markup you need.

3. Use conditional comments

If there is no suitable element that can be used to control the width and you can’t or won’t add extra markup, IE 5.*/Win needs to get a different value for width.

In my opinion, the safest way of doing that is to use conditional comments, which are comments whose content is only visible to IE/Win. In this case only IE below version 6 are supposed to get the contents:

  1. <!--[if lt IE 6]>
  2. <style type="text/css">
  3. #news {width:250px}
  4. </style>
  5. <![endif]-->

If you choose to use this method I recommend moving all IE 5.*/Win specific CSS to a separate file and load it like this:

  1. <!--[if lt IE 6]>
  2. <link rel="stylesheet" type="text/css" href="/css/ie5.css">
  3. <![endif]-->

This is a safe way of ensuring that only the browsers that need the modified CSS see those rules.

4. Use CSS hacks

Finally you can also use a CSS hack to supply modified values to IE 5.*/Win. I recommend avoiding CSS hacks as much as possible. Just like the name implies, these are hacks, and hacks that are based on undocumented errors in different browsers’ CSS parsing. Since many people still use CSS hacks I’m mentioning it anyway. I highly recommend that you consider other options before using them unless you know exactly what you are doing.

The simplest CSS hack for working around box model problems is The simplified box model hack, SBMH. Provided that the HTML is the same as in the first example, the CSS would look like this:

  1. #news {
  2. padding:10px;
  3. border:1px solid;
  4. width:250px;
  5. w\idth:228px;
  6. }

All browsers see and understand width:250px. IE 5.*/Win does not understand the next line, w\idth:228px, which all standards compliant browsers do. The result is that width is set to 250px in IE 5.*/Win and 228px standards compliant browsers, giving the list the same total width in all browsers.

Conclusion

As I have shown here it is possible to avoid or work around the problems caused by the different CSS box models. Which method you use will depend on the circumstances.

I should also mention that some time in the distant future, the CSS 3 `box-sizing` property will let you choose which CSS box model you want browsers to use. The W3C box model is called `content-box` and the Internet Explorer box model is called `border-box`. Being able to control this in all browsers is a good thing since each model has its pros and cons. However, browser support is currently too limited for this property to be of any practical use.

Hopefully none of this will be necessary in a couple of years. IE 7 was released in October 2006, and for every day fewer and fewer use the older versions of IE. It is already acceptable for some sites to hide all CSS from IE/5.* or to simply not care about the rendering differences.

I’ll leave it to you to decide when you can start hiding CSS from IE 5.*/Win.

CSS Elements Different Sizes in IE and Firefox

t’s happened to all of us, once upon a time, we might have coded a perfectly valid CSS and HTML file, only to find discrepancies between your website when displayed in Internet Explorer and Mozilla Firefox. (If you want to easily test your website across multiple browsers, I have an article on testing on various versions of Internet Explorer) Unfortunately, this is something we’re going to have to deal with. Internet Explorer 6 (IE6) and Internet Explorer 7 (IE7) have enormous market sharesand Firefox is slowly creeping behind them. This means when coding a website it needs to look good in both these browsers.

What’s the Problem?


Your Layout Is Slightly Different In One Browser Then The Other. Although to some people, a five pixel difference might not mean much, it might mean a CSS element on your website completely throws your whole website’s layout askew.

This is common. Although the problem I’m detailing isn’t always the problem occurring, it’s a good tip to keep in mind while coding and it will help you avoid most layout problems.

Internet Explorer and Mozilla Firefox both render Width and Height combined with Padding and Margins differently. What that means is, if you have a CSS element (paragraph tag, div container, span, header, etc.) that has a width and horizontal margin assigned to it, there’s a chance that something can go wrong. This applies to heights combined with vertical padding and margins and widths combined with horizontal margins and padding.

Here’s an image showing a simple .html file and the difference in how it’s displayed in each browser. Please note that the CSS attributes of each DIV container are typed out in the image. Click for a larger view.

CSS Elements throw Layout Off

Note how even though they each have the same HTML and CSS code, there are layout problems. In Firefox, the DIV containers are taller. In Internet Explorer, there is twice the margin between the first div container and the left side of the browser. This may not seem like much to you, but it can throw an entire website’s layout off.

What’s the Solution?

The solution is easy. Simply put, do not assign width and horizontal margin and padding attributes to the same CSS element. Also, do not assign height and vertical margin and padding attributes to the same CSS element. Some suggestions:

  • Use a div container inside your div container.
  • Use a p tag inside your div container. Add additional attributes to your p tag using CSS.
  • Create CSS elements that serve as spacers. (cue, horrible flashback to tables and spacer.gif’s)
  • Use absolute positioning, this nearly guarantees placement.

Hope that helps and clears out some mystery as to why websites seem to mysteriously shift between browsers.

Nghe cha dạy con gái

Một người không tốt với con, con không nên quá bận tâm. Trong cuộc sống của con, không ai phải có nghĩa vụ đối tốt với con trừ cha mẹ. Còn với những người tốt với con, con nên trân trọng và biết ơn điều đó. Nhưng con cũng cần phải có chút đề phòng bởi mỗi người khi làm bất cứ việc gì đều có mục đích riêng. Hãy nhớ, họ tốt với con không đồng nghĩa với việc họ phải quý mến con.

Không có ai là không thể thay thế, không có vật gì thuộc hoàn toàn sở hữu của con. Vì thế, nếu sau này người con yêu thương không còn ở bên, hay họ không còn là nơi con có thể đặt niềm tin, con cũng đừng bi lụy. Sinh mệnh con người thực sự ngắn ngủi, con đừng để mỗi ngày trôi đi vô ích. Người ta tham vọng sống lâu nhưng con chỉ cần sống hạnh phúc mỗi ngày. Hãy trân trong và yêu lấy cuộc sống hiện tại của con.

Trên đời này không có gì là nhất cả, tình yêu chỉ là cảm giác bất chợt đi qua cuộc đời con, nhưng nó sẽ theo thời gian và lòng người mà thay đổi. Nếu như người đó rời xa con, con hãy học cách chờ đợi. Hãy để thời gian rửa sạch vết thương, để tâm hồn con lắng lại rồi nỗi đau của con cũng sẽ dần biến mất. Con đừng mơ ước một tình yêu hoàn hảo, cũng đừng thổi phồng nỗi đau khi nó không còn.

Có những người thành đạt mà không cần trải qua nhiều trường lớp, nhưng điều đó không có nghĩa con thôi nỗ lực học tập. Kiến thức con học được chính là vũ khí con cần có, hãy nhớ người ta không thể làm gì nếu họ chỉ có tay không.

Con không nhất thiết phải chăm sóc cha nửa cuộc đời còn lại và cha cũng thế. Khi trưởng thành, con có thể tự mình bước đi, trách nhiệm của cha cũng đã kết thúc. Sau này dù con hạnh phúc hay buồn đau, con đều phải tự mình lựa chọn và có trách nhiệm với nó.

Con có thể bắt mình phải giữ chữ tín, nhưng không thể yêu cầu người khác làm thế với mình. Con có thể yêu cầu bản thân phải đối đãi tốt với người, nhưng con không thể kì vọng người ta sẽ làm ngược lại. Khi con tốt với họ, họ không có nghĩa vụ phải tốt lại với con. Hãy nhớ điều này nếu không con sẽ luôn gặp ưu phiền trong cuộc sống.

Cha đã mua vé số trong 26 năm thế nhưng chưa một lần trúng, điều đó nói lên rằngmuốn giàu có phải dựa vào nỗ lực làm việc của bản thân, trên đời này không có bữa ăn nào là miễn phí cả.

Chỉ những ai có duyên phận mới trở thành người thân của nhau,cho dù trong cuộc sống bận rộn con ít khi gặp mọi người, nhưng con hãy trân trọng từng khoảnh khắc khi còn bên họ, hãy dành cho họ thời gian để yêu thương con hơn, và hãy gọi điện cho mẹ con.