Change Code in multiple HTML files [duplicate] - html

This question already has answers here:
What are the new frames? [closed]
(3 answers)
Closed 8 years ago.
Is there a way I can change code in multiple static HTML files? I just added two new pages to the site, and the side bar containing links to all the pages need to be updated in all files. Is there a easy way to do it? Thank you very much.
Update: Also the side bar has an active row, which should be different in each file, is there a easy way to change that in each file as well?

notepad ++ allows you to search and replace and also has a reg-ex search and replace function you can use to replace all or replace via file extensions

The question you are asking has two good answers.
The first simple answer for your level of HTML knowledge would be to use a text-editors Find & Replace functionality to simply change identical pieces of code so all pages match. This would be the simplest answer for your question.
The larger answer would be to introduce you to the idea of a layout file. With this layout file(s) you could define your entire page layout, links, headers, etc. Then with each page you load you simply call the content you want to show inside the layout file. This is a high level concept and should ultimately be your goal to reduce issues like those which you stated in your question.
You can accomplish this with a variety of technologies such as PHP, ASP.Net, or Java EE development which are all very advanced stacks. The best starting point I would suggest is Server Side Includes. This will allow you to simply call the required layout text. While this solution is rather legacy; it might help you accomplish your task with grater efficiency.

Microsoft Visual Studio Express can find and replace in files.
But maybe it's time to refactor your pages and put the common information in a distinct file.

Related

Is it possible to add two links/files in a single import in CSS?

I was just wondering if it's possible to add two links to Google Fonts in one import, so I'd be able to achieve have less lines of code and smaller CSS files in general.
The closest to accomplishing this that I am aware of is #import. You can read more about it here: https://www.w3.org/TR/CSS2/cascade.html#at-import
However, for general use it is recommended that you simply include multiple <link> tags. See: Best way to include CSS? Why use #import?
The reason it isn't a regular thing is due to the nature of CSS being "cascading". You can't really place two stylesheets on the same "level" per se.
If you're getting fed up because of how large your header is, you can always create a universal file with PHP include. http://www.w3schools.com/php/php_includes.asp It can be irritating though as you cannot view the html file locally, it must reside on a server running PHP.

Webpage practice [duplicate]

This question already has answers here:
Is there an HTML/CSS/JS editor that immediately shows changes? [closed]
(6 answers)
Closed 6 years ago.
I have been learning HTML + CSS via online courses like codeacademy and W3schools. I have a very simple grasp as to creating webpages and I want to play in a "sandbox" by creating pages and just messing with stuff.
I'm looking for somewhere I can type in my HTML and CSS and have it display on a webpage just like any other page I look at. I haven't been able to find anything quiet like that, other than the courses themselves. Is there even such a thing?
You could try JSFiddle
It accepts JS, HTML, CSS and renders it realtime...
You can download a coding software such as Brackets. Save your html file as index.html and your css as styles.css (per example) in the same folder.
Simply click on them in your computer's documents and it should work, opening in your default browser. You don't need an "online" tool for html/css.
Also check out this blog post for alternatives
I would highly recommend http://codepen.io. I find it the most user friendly of the bunch
I think JsFiddle would work for what you want. It also allows you to incorporate javascript as you begin to branch out. Plunker is also something I would recommend as it has a "live preview" where your page will automatically display as changes are made.
Get a free website from a site like 000webhost. Then, you can upload and edit code in real time on the server and view it on eg. http://example.freehost.com and you can view it real time. Also you could use software like notepad++ and edit your code before uploading it. Make sure your homepage is index.html

Is there any possible way to give a <p> or a <h1> Tag. Something like a "src"? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I want to create Websites for small companies like restaurants. But i can imagine that i will often get called when they need help "Changing the text". Because they simply doesnt know better. Then i often will have do it for them. But there might be another way?
Image changing is simple. Just rename any Picture you want.
Like:
indexPicture.jpg
Everyone easily can replace those jpg. They simply rename any picture to indexPicture.jpg (preferable same size).
But when it comes changing to text. I can imagine a customer, that destroys html code. and removed some tags like (30 min work). Because he doesn't know better.
Can't I bind some text file to a <p> tag? So they simply have to open it and write something new.
Are there any better method?
Like a free App, they can open every website and simply drag and drop changes or select a <p> tag and simply rename it?
This isn't something that's really supported in basic HTML5, so the simple answer to a simple question is: no.
But life is never that simple in the modern web. If you're using a client-side templating framework like React or Angular (both are JavaScript frameworks which are freely available) you can code the pages to load fragments of text from disparate files which your client may have an easier time editing. I don't believe posting example code here is valuable to the question since that's basically a tutorial on how Angular or React work. There are great tutorials and examples on their sites.
As suggested in the comments the most accurate thing I can think of is to use a CMS. These are very helpful when changing the content of your site. Some examples are Wordpress, Drupal or Joomla. You can have a look here: https://www.ucl.ac.uk/building-great-websites/managing-your-website/using-a-cms
I hope that helps you!
You could try a shtml file instead? No CMS needed. I recently found out about this when creating my own HTML5 site as I wanted an easy way to edit a common footer rather than going through all the pages.
Just create a folder with the necessary files (Every paragraph maybe) and include it in the main file using a code like this:
<!--#include virtual="../filename.shtml" -->
I noticed that you didn't want to use a CMS such as WordPress, which as the comments suggest would be a really effective solution.
I once had an issue where I couldn't use a CMS cause I didn't have Cpanel access and what we essentially did was the follow.
Define a XML file, with clearly defined tags for each section of the
website that the client may want to change periodically.
Access the XML file through PHP(something like SimpleXML), and
display the tags/relevant content in the page.
Create a backend that allows the client to view/update content
through forms.
Alternatively, you may use a similar solution with databases and give forms for editing.

Menu from external file [duplicate]

This question already has answers here:
What are the new frames? [closed]
(3 answers)
Closed 9 years ago.
I am now making a webpage and need a bit of help. Its been some time since Ive done my last page a few years ago. Back then I remember it was quite popular to use frames, but these days, this is basically no longer used.
What I used to do is have a horizontal menu on the top as a frame, and underneath it the content frame.
Now, currently I have a webpage again, where I would like to place a horizontal menu on the top of the page.
The menu is written in pure CSS and HTML. The CSS is loaded from an external file, but the problem I now have is that the menu is basically a DIV element, which however I have to put into each page separately.
I was just wondering there must be a way of making this simpler and have it somehow inserted from an external file again - sorry maybe it sounds confusing, but basically I am looking for an alternative of the frames used in the past. Many pages have menus and I am sure they do it somehow, because if I make a change in the menu, I dont want to be making these changes on all the hundreds of pages.
I dont ask for any specific coding etc. I can google that myself if I dont know how to do it, but I just need a general recommendation how to solve this. Just to summarize, the menu is in HTML+CSS and the pages are mostly PHP, some of them HTML.
I'd think it would mostly depend on the framework. You could just have one page, and use AJAX to load the content of each page, or you could have several php pages, all of which call some function at the beginning to set up the header, or you could use a ASP.NET master page or whatever your framework uses.
If you're using PHP, then the easiest way would be :
<?php include('my_page.html'); ?>
Be carefull of the path to your html page

How to include duplicate markup in every web page [duplicate]

This question already has answers here:
How to create a template in HTML?
(3 answers)
Closed 8 years ago.
If all my web pages have the same navigation and footer markup, what is the best way of avoid hard-coding this in every page, so if it needs changing it's only changed in one place so as not to have to edit every html file?
Thanks
A few options:
Use a static HTML generator, which will allow you to use template and pure HTML.
Use server side includes if your server supports them.
Use iframes.
Use any server side language, and its templating counter part (php, jinja2, django, et. al)
Use the AJAX load() method.
$('#mysection').load('yourfile.html');
Of course the URL can also point to a PHP script etc.
http://api.jquery.com/load/
You should use a server-side solution depending on the technology that are you using (PHP,ASP,etc...)
I think you should take a look at this link.