Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Coding CSS for Webpage to Read .TXT File


  • Please log in to reply

#1
TeachPower

TeachPower

    Member

  • Member
  • PipPip
  • 84 posts
Hello all. I hope you all are having a great Christmas holiday.

I am redoing a simple webpage for my father-in-law for our military collectables and antiques family business [old site: pinomilitaria.com]. He is not very computer literate and thought it would be easier for him to write/change descriptions for each of the collectables via a .TXT file. Then all he would have to do is upload the .txt file to the hosting server and the page would read it and display the text. I was figuring that this could be done through a CSS. Could someone tell me how to go about doing this so I can get him up and running.

Thank You.

Edited by TeachPower, 30 December 2010 - 03:27 PM.

  • 0

Advertisements


#2
Coel321

Coel321

    New Member

  • Member
  • Pip
  • 7 posts
Hi there,

I used something like this on my website, although I did not do it with CSS.
There's a method to just use HTML to accomplish this:

<p><font color="#FFFFFF"><embed src="filename.txt" width="x" height="y"></embed></font></p>

It will display the text in the .txt on your website, with transparent background(so it's not white like when you open the .txt in notepad)
Set the width and height to your website's dimensions, otherwise it will produce a slider. Changing font color is, ofcourse, optional.

I hope this satisfies you :D

Coel321
  • 0

#3
AstraNut

AstraNut

    Member

  • Member
  • PipPipPip
  • 465 posts
To always update content and keep it simple the file would have to keep the same file name. You could try making an HTML page which will call the text file. Something like this:

<div style="margin: 0 auto; width:100%; height:400px; overflow: auto;"><object type="text/html" data="file_name.txt" style="width:100%; height:400px; margin:1%;"></object></div>

Play with the styling. In fact, you might want to remove inline CSS and add the CSS to your external CSS file. Just set an id name for the div and object tag.
  • 0

#4
TeachPower

TeachPower

    Member

  • Topic Starter
  • Member
  • PipPip
  • 84 posts
Thanks for the prompt responses. Each page has is going to feature 10 collectibles at a time in row form. I was hoping that I could have him write all his descriptions for each item he is selling in one .TXT file (properly formatted) and have that page read the file and display the text for each item accordingly. Therefore I could have one .TXT file per webpage. I don't know how to setup the code withing the page to read that .TXT file and how to setup the .TXT file so the page can read it properly. Hope that helps.
  • 0

#5
AstraNut

AstraNut

    Member

  • Member
  • PipPipPip
  • 465 posts
A .txt file only has basic formating so there's not much fancy stuff you can do with a total text file. Could use Word and have him save it as an HTML file after each edit. Of course, Word puts in a lot of Microsoft Schema and will not validate properly. You can then use them as a link in the nav menu.
  • 0

#6
TeachPower

TeachPower

    Member

  • Topic Starter
  • Member
  • PipPip
  • 84 posts
I don't want to do any fancy stuff with the .TXT file. The fanciest I want to get is bolding, italicizing, and/or sized font; and I was hoping the CSS file could read that text in the file and apply any bold, italics, and/or font change to it when it displays on the webpage. Is it possible and to code the CSS to do that?
  • 0

#7
AstraNut

AstraNut

    Member

  • Member
  • PipPipPip
  • 465 posts
Not for a file with the ".txt" extension. CSS will not be used when the browser parses the page to display it as text only. You already have some formatting in a text file, but it is basic stuff. An html file would allow you to use CSS more powerfully with the text you want to have display provided it is wrapped in HTML tags. Possibly a Content Management System would work for updating content as needed. Or, possibly you could use Server Side Includes for the content update. Using the Includes would allow use of one include file that could be set up to be easily changed according to content. Then the include file(s) would be uploaded and overwite the old include file of same name to replace the old content on the html file. Not sure if this would work as it would depend on how easily you can make the file editable for text only and teach them to upload the include file(s) using FTP. The only other way is possibly to set up a server-side script which would allow uploading the text content only to be display. Little more complex as to the script set up as it would probably have to be written from scratch.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP