I have tons of html files, every html file has CSS code at the top telling the html page what to look like. EVERY html file has the same CSS code. If I change the CSS code in one, I have to go through ALL of my html files and change it in them to.
How can I point my html files to a single CSS file so that when I change that file it changes the look of ALL of my html files at once?
As you can imagine linked style sheets are preferable to writing out the CSS code in the head of the page because it's much easier to manage and faster to download.
Yes, you can LINK your documents to an external style sheet!
e.g.
<link rel="stylesheet" href="styles.css" type="text/css" />
But there are pros and cons...
Pros:
*Can set and update styles for many documents at once.
*Style information is cached by the browser, so there is no need to repeat.
Cons:
*Requires extra download round trip for the style sheet, which might delay page rendering, particularly when multiple files are in use.
*In some cases when @import is used, the browser may cause a rendering "flash" under slow loading conditions.
But as I feel, in your condition there should only be pros!!! :-)
Using an external stylesheet is best practice for website design. The delay in rendering a page caused by using an external stylesheet is trivial in comparison to all of the other external components on a page. And if you're using the same stylesheet throughout your site, browser caching will mean users will generally only have to download it once per visit.
So don't give it a second thought. Good luck!
I know this is a long shot, but I have another problem with the same setup. I now have all the html files pulling style information from a master CSS file. However, If I make a physical change to the html file I have to go change the html in every html file so they are all the same.
I have multiple html files that are essentially tables of information. The information for each html file is different, but all the tables are the same. If I add a new table to hold additional information, I have to add that new table to each html file individually. Is there a way to use a single html file for my table layout and populate their information separately?
Yes, in the web developing world there is a solution to each and every type of problem!!!
Your problem can be solved using PHP!
I am sure that it can be solved but I am not sure how to do it... as I have just started to learn this language!
But then also I guess you can solve the problem using the SSI (Server Side Includes).
They help you to insert the content of one PHP file into another file before the server executes it, with the help of "include()" and "require()" functions.
There is also a possibility that I may go wrong... so I am waiting for somebody to throw light on this problem's solution!
I know this is a long shot, but I have another problem with the same setup. I now have all the html files pulling style information from a master CSS file. However, If I make a physical change to the html file I have to go change the html in every html file so they are all the same.
I have multiple html files that are essentially tables of information. The information for each html file is different, but all the tables are the same. If I add a new table to hold additional information, I have to add that new table to each html file individually. Is there a way to use a single html file for my table layout and populate their information separately?
No. Server side programming (in PHP, Ruby, Python, etc.) is usually the way to handle that. It could be done in the browser with JavaScript, but that's not typical. HTML by itself has no way of reusing boilerplate structures other than by simple code copying, in which case problems like what you're now facing are inevitable.
Any chance I could get a link to a page that can teach me how to use php to do what i'm asking?
I can give some you tips.
First make sure PHP is available on your server (it probably is, PHP is maybe the most popular server side language). Then get an overview of the language, maybe here.
This is not going to be an easy task, could take weeks or months.
There are 2 main parts here, 1 is to get the data in the form of a 2 dimensional array, the other part is a function that takes that data and outputs an HTML table:
The above function is the part that only needs to be done once. I don't know about the code that assembles the data in a 2D array. Depending on what form the data comes in it might need to be written for each batch or it might be able to be a group of functions that gets reused.
The important thing is to keep the 2 pieces, the data assembling and the table outputting, separate and not intermingled. You could work on the data assembling and get someone else to work on data outputting.
One other thing, when you're searching about tables understand there are HTML tables (which you're concerned about here) and there are database tables, which are something different.
Im an advanced programmer and i would say high end beginner in web development. I understand the basics of html php css and javascript.
Its just hard for me to do things in php from scratch at this point.
My idea is to have a form that uses php to send the data to the database with an id
Then i enter the code into the page including the id of the data set i want to load. It runs another php file which draws the table with the content in the database from the id i specified. That way to make a change to all pages, i can simply edit the php file that pulls the data from the database and draws the tables.
Essentially it will do exactly what phpbb does. The topic page is a static template html which is loaded visually. It uses php to pull data from the database and fill the topic info. It knows which topic info to get via topic id
Bookmarks