Ok, not sure if it's doable and how it's done, so l have come here :) Now what l am after is this, l have a css file and a html file, now in my html file l would like to be able to load in data from a .txt doc and apply the styles from the css file. the .txt doc will contain html. here is my main issue if l do this will positioning be an issue? And what html could l use to do this? if you are wondering why l am after this it is for easy editing for people when do not understand html very well, and if l can make all the menu's on the site load from one .txt doc l only ever need to change that 1 .txt file and it should remain the same on every other page of the site.. so doable?

Recommended Answers

All 5 Replies

To display another html file in a page you use the <iframe>:

<iframe src="yourpage.html"></iframe>

This can be styled for the height and width.

The source should be full html (everything; header, body, etc.) document and not just snippets of code - just in case you were going to do that.

To use your CSS file in the source of iframe simply link to it as you would with any other html page (put in header):

<link rel="stylesheet" type="text/css" href="mystyle.css" />

Lastly, positioning shouldn't be a problem, simply position iframe as you any other element in the page.

"The source should be full html (everything; header, body, etc.) document and not just snippets of code - just in case you were going to do that."

Ummm, yes, this is sort of what l was gunna do, load everything from other files for easy editing for people who don't understand html, any other ideas???

Well, it sound likes like you want php (getting into a different area). With php you coud creat a dynamic webpage, i.e. the content can be changed with out editing the source code manually. A page with purely html and css is static - the content can't be changed without editing the source code.

Using PHP, you could creat a page where users enter values for certain areas of the website, via form fields. The site that you want people to be able to edit would have PHP variables for anything that would editable, and when users submited their content, the PHP would take it and put it into variables, which would change the site with out the user ever seeing a single tag. Of course for you, this woud require many (many) hours of coding (& learning), as PHP is quite different from html. You also have to upload the pages with PHP to a server where you could test them, as php is a server side language, and does not work when simply viewing a page off of your hardrive.

mmm, ok, just thought anyway, my site is going to have a login so l might as well keep going and create a cms system of some sort... l am still working on the login system, have the registration bit mastered, login in l can't find a good tutorial on yet :( anyways thanks again. you have answered my queries and questions for now...

<html>
<head>
<style type='text/css'>
div {background:#ddd; color:black; margin 0 auto; width;85%]}
</style>
</head>
<body>
<?php echo '<div>'.file_get_contents('textfile1.txt').'</div>';
echo '<div>'.file_get_contents('textfile2.txt').'</div>';
echo '<div>'.file_get_contents('textfile3.txt').'</div>';
echo '<div>'.file_get_contents('textfile4.txt').'</div>';
echo '<div>'.file_get_contents('textfile5.txt').'</div>'; ?>
</body></html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.