How many id-s and classes...

  • HKt0p5
  • Graduate
  • Graduate
  • User avatar
  • Joined: Mar 19, 2008
  • Posts: 134
  • Loc: Bulgaria
  • Status: Offline

Post February 21st, 2009, 2:23 am

How many div id-s and p.classes and a.classes can I have in a css file and in an HTML file?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 21st, 2009, 2:23 am

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post February 21st, 2009, 6:19 am

There could only be two logical limits on such things.

1) Limits imposed by browsers by design of the rendering engine, likely different from browser to browser
2) Limits imposed by a computers available resources, which will vary from user to user

In either case I would be willing to bet the number is high enough that you should never realisticly have to worry about it as a developer.
Strong with this one, the sudo is.
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post February 21st, 2009, 6:45 am

Out of curiosity I generated a 20.8 MB CSS file that includes 500K unique ID and class CSS rules (for a total of one million) using the following script and tried it.

Code: [ Select ]
<?php
ini_set('memory_limit', '256M');
$str = '';
for($i = 0; $i < 500000; $i++)
{
    $str .= "#_$i{color:#fff;}\n";
    $str .= "._$i{color:#fff;}\n";
}

file_put_contents('test.css', $str);
unset($str);

?>
  1. <?php
  2. ini_set('memory_limit', '256M');
  3. $str = '';
  4. for($i = 0; $i < 500000; $i++)
  5. {
  6.     $str .= "#_$i{color:#fff;}\n";
  7.     $str .= "._$i{color:#fff;}\n";
  8. }
  9. file_put_contents('test.css', $str);
  10. unset($str);
  11. ?>


On Ubuntu/Gnome, Opera and Firefox became unresponsive for 5-10 seconds, then displayed the page.
Strong with this one, the sudo is.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 165 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.