Kompx.com or Compmiscellanea.com

CSS. Target Firefox only

Windows : Firefox 1.5+ [ 1 ] [ 2 ].

Linux : Firefox 1.5+ [ 3 ].

CSS targeting Firefox web browser only:

This text is red in Firefox

HTML / XHTML. Code:

<p>This text is red in Firefox</p>

CSS. Code:

@-moz-document url-prefix() {p {color: #f00;}}

Unlike the method of styling elements for Opera browser only, it is essentially a hack - since the rule originally is intended for a different purpose. But lack of support in browsers other than Firefox allows to isolate code for use by Firefox web browser only.


[ 1 ]

Other browsers with Gecko web browser engine, like SeaMonkey 1.0+ or older Netscape 9.0, also support the hack.

[ 2 ]

Various versions of Internet Explorer, Google Chrome, Opera, Safari react to the hack as they are meant to - these browsers ignore the whole code of the Firefox specific hack.

[ 3 ]

There is also one more browser where text gets red - ELinks, an advanced text-based web browser with some support for CSS.


Aliosque subditos et thema

 

HTML centering

 

Centering the whole content of a web page in the viewable area of a browser by pure HTML - no CSS. A box to keep the content of the page is HTML centered horizontally and vertically - [ Open demo page ] HTML. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>HTML centering</title> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252"> </head> <body bgcolor="#ffffff"> <table width="100%" height="100%" bgcolor="#a3ddc4"> <tr> <td align="center"> <table width="800" height="500" bgcolor="#ff6f6f"> <tr> <td>&nbsp;</td> </tr> </table> </td> </tr> </table> </body> </html> The outer HTML table makes the whole web browser viewable area, except margins, a HTML table and the whole area of this HTML table - a HTML table cell. The cell of the outer HTML table inherits the default value for valign attribute from its parent table row. And this row in its turn inherits the default value for valign attribute from the outer HTML table tbody - even if tbody tag is not used. And that value is middle. So a block of content inside the cell of the outer HTML table is centered vertically in web browser viewable are. Align="center" of the outer HTML table cell makes a block of content inside it centered horizontally in web browser viewable are. The inner table, the one inside of the outer HTML table cell makes up a box of a given size. Or there may be no set height or no set width or both. Then the size of the box is to adjust to accommodate the content, whatever its dimensions are. If the width or height or both of the box results to be larger than web browser viewable area, then it still ends up to be centered. Since HTML centering is the oldest method to center content horizontally and vertically, it works well not just in older web browsers, but in ones that can be described as downright ancient. Like adding one more HTML tag ( <center></center> ) around the outer table makes it funcion as deep as Internet Explorer 3 : [ Open demo page ] Download Internet Explorer 3: a pack, containing 3.0, 4.01, 5.01, 5.5, 6.0 versions of Internet Explorer HTML.

CSS centering <hr />

 

CSS centering <hr />, if its width is less than 100%. Horizontal centering. Example: HTML / XHTML. Code: <hr /> CSS. Code: hr {width: 50%; margin: 0 25% 0 25%;} /* Extra CSS, just styling the look: */ hr {height: 1px; float: left; border: 0px; color: #f00; background: #f00;} Note: mostly it works both with float: left and float: none. But float: left makes it for sure. [ 1 ] As well as Netscape 4.04+, Mozilla 0.6+. [ 2 ] As well as Netscape 4.04+, Mozilla 0.6+.