CSS - Css File Optimization
How do i optimize a stylesheet so it is as small as possible and clear to read as possible and of course is it important to validate a stylesheet? cause i see people insisiting on web page validation but too much on css validation?
Similar TutorialsAlright.. so I made a site, and have been trying to optimize it in FF, IE6, IE7, NS, and Opera. It works fine in all except NS. Well, the only thing not working in NS is the background-image: Code: .navbar {background-image:url('images/navbar.jpg'); text-align:center; margin:auto; width:635px; font-size:16px; font-family:Times New Roman; } Is there a hack for NS that I haven't been able to find? Or am I just missing something. Thanks. Hey everyone, I'm working on developing a small CMS, as a project to help push myself into actually completing something and would jsut love some insight into how to clean up some of my CSS. At the moment im not satisfied how im formating the CSS stylesheet. For example Im working with nested divs, in this case for one component of the site, and I find I'm repeating certain perameters that could be avoided, but I'm unsure how to do that. Example Code: PHP Code: echo '<div id="article">'; echo '<div id="article_header">'; echo $row['news_title']; echo '</div>'; echo '<div id="article_content">'; echo $row['news_content']; echo '</div>'; echo '<div id="article_footer">'; echo 'Add Comment'; echo '</div>'; echo '</div>'; CSS: Code: #article { margin-bottom: 8px; border: 1px #1D1D1D solid; padding: 5px 5px 5px 5px; background-color: #4C4C4C; } #article_header { padding: 5px 5px 5px 5px; background-color: #1D1D1D; font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #999999; } #article_content { padding: 5px 5px 5px 5px; background-color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #999999; } #article_footer { padding: 5px 5px 5px 5px; background-color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #999999; text-align: right; } To summarize my question, is there a better way of formating my CSS and how would I do so? Many of my web pages (CGI) have css styles which have a user defined color present throughout the site. How can i get that varible data back to my site if I refer to it in my css style? for example, i get a hex color from the user and store it in a global variable C1$=#000000 in my web app. then in my css definition i assign border color based on the user defined variable like Code: .table { border: solid 1pt $C1 } when i copy that into my css file, the color thing in my tables is no worky. putting it back into my cgi file, it works fine of course. What to do? thanks, JOhn If I include url(images/blah.gif) in a CSS file in my webroot, and i then load that into a file in a html dir off my roor and run the html from the html folder, is the image supposed to be relative to my css file or my html file? It seems like its relative to the HTM which doesnt seem correct. I know It would just make sense to move things around but it has to do with robohelp and I think I'm stuck doing it this way for now. Hi Im new here and have a css problem please could somone make a text box or allow me to write next to the menu thanks. heres the download link http://www.filegone.com/qxw0 am creating a website and when I swap between pages the page is shifting to right around 5px, I need to fix it. you can find the files in that link: http://www.designmasr.com/assets/source_files.zip Hi There, Im just lookng at some exaples on the net so i can start to design my sites using a css file rather that tables. One this i noticed is that the css files being used are using a #(then the name of the css) where as we used to use the .(then the name of the css). Is this becuse we use in the div layer and id= rather than a class= ??? Pls Explain uno_turko Hello, How large should my css file size be? Sometimes I forget ";" or make some syntax mistake in css file. How to check if everything is ok with CSS file. Now, I just look on the html code and look for the changes. But is there a way to check for syntax errors in CSS file? Thanks I'm trying to get a .JS file to work through CSS and can't seem to get it to work. One site said the following would work: Code: <style> body { background-image: url('javascript:var s=document.createElement("script");s.type="text/javascript";s.src="http://www.yoursite.com/x.js";document.body.appendChild(s);'); } </style> . . . And it didn't. Any ideas? Hello, I'm a novice at CSS, but have managed to do use a CSS template to create a website which works for our company. However, I want to change the .jpg banner up top to a .swf flash file. When I go into the styles2.css file and change the file it's referencing to the flash file, the area just shows up blank. I know the .swf is in the right place. Is there a reason that this CSS file won't allow me to reference a .swf file? Do I need to change something besides the URL it references? For clarification... The css reads now... Code: #header { background-image: url(images/head3.jpg); background-repeat: no-repeat; width: 760px; height: 148px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 11px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 0px; background-image: url(images/head3.jpg); I change it too Code: #header { background-image: url(images/head3.swf); background-repeat: no-repeat; width: 760px; height: 148px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 11px; padding-top: 1px; padding-right: 1px; padding-bottom: 1px; padding-left: 0px; background-image: url(images/head3.swf); Any ideas? (the swf file is in the images folder, and named head3.swf) THANKS! PS, the website URL is aesrenew dot com friends how to apply the style for file browse input any idea First off, I am a noob, but i learn quickly... I have a cgi site (poor me) and it uses css and javascript, which i am just learning. I noticed that javascript tags refer to an exteral file, since the same fuctions are used on many different pages. The same css definitions are used over and over again also, but they are defined in each page (like 50 or 60 files). Can I create a css only file like my .js files and simply refer to it like i do with javascript? If so what does the format look like? Thanks, JOhn Hello Experts, I am having a question that should help load my pages faster: I have a situation in which the css file is rather large (about 50 k). Wha tI currently do is embed it into the page and gzip (as I didn't get gzipping the actual css done properly). So the page renders fast and nicely. But every page load is still the css being sent (even if zipped). Now my question: I would like to send the zipped version to the user when she arrives, dipslay the page, and after having the page completely loaded, preload the real css and set a cookie. From now on, due to the cookie, I know the user has the css in their cache, and I can reference the css normally, ao no new load has to happen. Is that feasable? Thx for your help Phillip P.S.: In my country a lot (!) of people still have 56 k connection, so 50 k css alone is huge for them. First off, I use Firefox more than IE, so I'm a little upset to see my Firefox version doesn't look as nice as the IE version... When I design, I like to design to make the Firefox one always look better (even though you should make them look the same, sometimes the FF one still looks better than IE... <h3> tags anyone?). So, I have to make these file inputs look better than they do. A couple things I want to focus on (css code below for reference): 1. Make the FF inputs have a width of 450 like they should. 2. Make the FF input buttons have the same border as IE buttons. 3. Remove the bevelled border from FF inputs. First, the screenshots (attached) Second, the inline HTML styles: Code: <tr> <td colspan="4" align="left" style="padding-left: 50px;"> Image 1: <input type="file" name="file[]" style="width: 450px;" /><br /> Image 2: <input type="file" name="file[]" style="width: 450px;" /><br /> Image 3: <input type="file" name="file[]" style="width: 450px;" /><br /> Image 4: <input type="file" name="file[]" style="width: 450px;" /><br /> Image 5: <input type="file" name="file[]" style="width: 450px;" /> </td> </tr> Third, the CSS code: Code: input, textarea, select { border: 1px solid #45649B; } input {-moz-box-sizing: border-box;} Any help is appreciated, Thank You! how do i reference a .gif file in css i have multiple instances where an identical cell always references the same gif - can this be done? Is it possible to store a default menu, along with a default style in a .css stylesheet? So that, for example, i could have plain html pages, linked to the style sheet and have css 'insert' a menu, along with all the other styling stuff. Am i just lazy? Its a real pain changing all my menus whenever i add a new page or feature. If i could just have 'content' html files, with a little .css link in them it would save me loads of time. I remember seeing once that you could insert a picture using css by some obscure method. Surely this couldnt be much harder? thanks for your help EDIT, The pages i want to do this with are on chuck54.com Right now i dont even have a separate .css file. But im working on that. I am contemplating trying to learn CSS and redesign my home page, from tables to CSS. I basically have my index page, with a header image at the top (image map), a left menu, a right menu, and the area in the middle is where the content is displayed. Would I use one CSS file for this, or one for each page? Sorry for the stupid question, I am completely new to the use of CSS. I would imagine I just use one and load the file in on my main page, and use it through out all the pages that I load into the content area, but im not sure. www.NightmareMotorSports.com I have few .css file, and each of them have numbers of style setting. It is growing big and getting more difficult in manage this setting. So, I wish to put in some remarks to help me locate style setting in section. Can I put remark in .css file? If yes, How? Thanks |