I was wondering if there is any kind of software who can read an HTML document within a lot of inline styles and convert all these styles into an external css file.
If it was only one page, i could do it manually. But there are 100 pages.
Anybody an idea?
like someone said, 'there's an app for that'. Here it is: http://www.cssout.com/
Try this online tool CSS Out
Read this Dreamweaver help
You can do it easily with PHP. Either use a regex expression (preg_match) to grab content amongst <style> tags or use DOMDocument class as mentioned here
Get text between HTML tags
Related
I am working on service which allows third parties to upload HTML snippets. In some of these snippets there may be links to CSS files or inline CSS. The service has it's own CSS files.
Is there any way, besides iFrames, which would allow me to indicate that specific CSS files are only to be applied to the specific HTML elements and not the whole page?
I guess you could download the CSS-files, prepend some #unique-container-identifier to all rules within it and just embed the markup into your page, inside a container with the ID previously assigned.
That'll leave you with a problem of your own, "real rules", ruining things inside those boxes though...
Unfortunately no solution I've found on the interwebs seems to work for me, so I just had to scrap the idea of using scoped CSS.
i would like to make 'skinnable' a web site written in asp.net...
I explain: for example, i have a 'div' element, and i would like to define a background-color using a variable, not a fixed value.
How can i do ?
Css ? Or other tecniques ?
Thanks
CSS is exactly what your are looking for.
Keep in mind that when writing your classes and ids you should refer to the element semantically. It means you should NOT choose your names depending on the visual representation of the element.
Wrongs:
.blue
boxOnLeft
Goods:
.comments
related
To be able to skin your page, you'll just need to change your css.
Almost all is possible using CSS.
ASP.NET has built-in functionality for Themeing and Skinning:
ASP.NET Themes and Skins - MSDN
You could always roll your own as well. The general idea is that you have a seperate set of CSS for each Theme/Skin and then generate the references dynamically based on what Theme/Skin the user selects.
You might look at .Less and t4 template package for it:
http://haacked.com/archive/2009/12/02/t4-template-for-less-css.aspx
A lot of good notes in the comments of that link as well, including a visual studio addin.
CSS doesn't have programming variable capabilities that you hope to achieve.
However, there is a way to do this with PHP (I know you're looking for .NET solution here, but bear with me)
Basically, you add a line of header text "", save the css with .php extension, and then load the .php in html as css (""). Then you can manipulate variables with PHP.
I don't know anything about .NET, but I believe it should be possible in a similar manner.
I have looked for a good solution for rendering a PDF based on a web page / HTML string, that can also keep the CSS styling.
Does anyone know of any good solutions for this?
Thanks in advance.
TRY ABCPDF
I have successffully used in the past.
I've used the free and open source iTextSharp before with some success. I don't think it supports the case where you have a separate .css file, however it does apply inline css you use (the style attribute).
Typically you end up having to create a separate XHTML page for PDF generation with inline styles (and sometimes tables) in order to get the PDF to look right.
I am using the django framework and am using templates, inheriting a lot of admin base templates. What am wondering is: can I have more than one CSS file in one HTML file? i.e. maintain the django admin CSS file but then have another CSS file of my own with different styles!
Yes you can. Just place the tags to the CSS files or embed the style in style tags.
Just to add that whilst multiple css files are of course possible, it is actually best practice for you to merge the css (programatically if possible) into as few files as possible.
Fewer files = fewer http requests = better responsiveness for the end user.
Yes, you can. But if you try to override any of the CSS in the django admin CSS, you'll have to use !important in your style definitions.
Of course, that's why they are called Cascading Style Sheets, because you can have a dozen of them applied in succession.
I'm wondering if anyone knows of a tool that will help me identify obsolete css (declared styles that never get used) in my site.
thanks!
See CSS cleaner here on SO.
Since stylesheets can be added with script, and elements and classes can be created with scripts, it could be risky to remove css class and id declarations if they are not found in the html of those pages that literally link to those stylesheets.
That said, perl is a good tool for any kind of sitewide search and replace operation.