Style sheets for content?

Forgive my ignorance, as it is like what I should know.

I know that I can create a stylesheet that will allow me to make changes to my CSS across multiple pages using CSS. I also know that you can create an external javascript file that may contain functions that you want to reuse. But let's say that I had pure HTML content (let's pretend to be a bunch of buttons or links) that I would like to reproduce on several pages. Is there something similar to a stylesheet in this regard? This will allow you to update buttons / links at the same time.

+6
javascript html external stylesheet spry
source share
8 answers

Try the server side.

The most common use of SSI is to include the contents of one or more files in a web page on a web server. For example, a web page containing a daily quote may include a quote by placing the following code in a web page file:

You can also use PHP if your host allows this. Just change the page name from .html to .php and specify a title:

<?php include "header.php" ?> 

Both of them require changing the file extension, so you can also use mod_rewrite so that users can access it through .html . Again, if your host supports it.

+3
source share

The question is not that this is stupid, because in fact there is nothing native to it in HTML.

If your server supports your server, you can use Server Side Includes. If you have PHP, you can also do <?php include "footer.html"; ?> <?php include "footer.html"; ?>

All other server languages ​​have a similar design.

+1
source share

Depends ... I know that Dreamweaver has pretty advanced template support. You can delve into the manual of your WYSIWYG HTML editor and learn how it can help you with repeatable content elements. Otherwise, as Simon hinted, you should consider learning some server-side technologies (a scripting language such as PHP is a simple choice), write your repeatable HTML and give the scripts an output when and where you need to. Good luck

+1
source share

You can try using the CSS content property, but the content is inserted after / before the target. http://www.w3schools.com/Css/pr_gen_content.asp

EDIT

You can also try storing your content in XML documents and use JavaScript to load XML sheets. Each sheet can store the contents of your button, input content, etc. All you have to do is parse the XML and display the content as HTML elements.

0
source share

It seems you are not using some server technologies, such as ASP.NET, that have user controls on which you could place them.

An alternative would be to use Server Side Includes, for example :

 <!--#include virtual="header.html"--> 

Grz, Kris.

0
source share

While SSI seems like a better idea, I suppose if memory helps me well, that if you use IIS, you will have to configure some settings on the server to work with SSI with the html file extension.

Although the idea of ​​SimpleCoder does not seem to be a better idea, it is interesting. Based on this idea, it might be better to use json data instead of xml. I would play with it just for fun.

0
source share

If neither SSI nor PHP is available, you can only do this using javascript: Load the page in a hidden IFRAME, then grab it (using innerHTML) and move it to where you need it.

0
source share

If you don't care about SEO, I would advise against using javascript for this purpose.

Perhaps, but such a method can prevent search engines from properly indexing your site.

0
source share

All Articles