Is the content on a HTML page all literal values?

I have a question about HTML files. Some HTML pages have only static content in them. Others are created using dynamic content, e.g., content that is pulled from a database.

My question is whether all the final content in the HTML files are literal values, whether they were originally static or pulled from a database, or  do they also contain variables, etc? For example, if I were to copy all the code from a HTML file and paste it in a new blank file, would I see exactly the same HTML content in the browser? What about the styling aspect of it? If the HTML page used stylesheets, how would that affect the new page?

Thank you.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

No they are not all literal values, these days they are mostly interpreted and processed from server side.
ASP and PHP are all server side languages and widely used, there are also others but the main purpose of these is that the client is not exposed or intercepts sensitive data.
The combinations vary, however all SQL data and variables are stored on the server.

Copying and pasting the HTML code will not get you the whole story unless it is a basic/static  web page.
Dave BaldwinFixer of ProblemsCommented:
Content is often added after the page is loaded using a function called AJAX.  In those cases, copying the original HTML is not going to get what is shown in the browser.  In addition, external javascript, CSS, and images are not going to be there either.
Tom BeckCommented:
if I were to copy all the code from a HTML file and paste it in a new blank file, would I see exactly the same HTML content in the browser?
I do this all the time for troubleshooting html pages, even dynamically created ones. However, you sometimes need to go through using find and replace and change all relative urls to absolute urls. A stylesheet for example, will be fetched from its original location and all the page's styles will render on your local copy of the page. Of course, editing linked assets is not possible when they come from remote web servers. To edit you must download the asset, save it locally, and change the include tag back to a relative local url. And as Dave pointed out, any content loaded asynchronously will not display in any case.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

geeta_m9Author Commented:
Thanks, what about the content itself? If the values in the browser are being output from variables, will it be the actual, literal values that appear in the browser?
It will the values that you copied when you copied the code.
Tom BeckCommented:
Don't confuse the DOM with the browser source code.

If you are looking at a page that was generated dynamically using some server side language like php for example, all markup that the php code produces you will have in the browser source code.

However, if some of that browser source includes client side scripting like javascript/jQuery that is altering the markup or styling during page load, then those changes in content can only be seen in the DOM using a tool like Firebug. The browser source code remains unchanged.
Julian HansenCommented:
Here is what happens with a HTTP request.

1. The browser makes a request to the server for a resource (page, image, video etc) in the form of a URL or etc

2. The server runs some rules to decide how to deal with the request AND how to return it. If the request matches a resource the server is permitted to return (such as a static HTML page or an Image etc) it then returns that to the browser using the appropriate headers to indicate what the content is and how it should be interpreted.

3. If the URL points to a resource such as a script the Web Server launches the process that knows how to deal with that script. The script then runs and does what it needs to do (access database, calculate PI to 300K places - whatever). The output of the script is effectively a static web page - i.e. the HTML that comes out of it is fully rendered HTML with all variables translated and controls rendered etc - by looking at the page source in the browser it is (in simple terms) impossible to tell if it was typed in by hand or created by a script.

4. This page is then sent to the browser which loads the page and starts rendering it out by interpreting the HTML tags and translating them into screen output. When the browser encounters HTML that refers to an external resource (such as a style sheet, javascript file, image, video etc) - it performs another request to the server to fetch that resource. This carries on in the background while the browser continues rendering the rest of the page.

5. When a resource is finished loading it is added to the page in the place it was specified in the HTML markup.

6. Any javascript that is not contained within a function or page load event handler is executed as it is encountered - this may include code that writes to the page while the page is loading in the browser - an example of this would be
document.write('Hello World');

Open in new window

Which would result in the string Hello World being written to the document at the point the line of script exists in the file.

7. Resources like stylesheets are applied to the HTML and the default page styles are replaced with the styles in the sheet giving the page the look and feel the creator intended.

8. When the document has loaded it then fires off any on load event handlers that might have been defined - these might bind additional event handlers that respond to user input or perform further page configuration functions or send data off to some location (like Google Analytic s) - there is no limit (within the confines of scripted code) on what can be done.

9. When events occur on the page any event handlers attached to those events are fired and do whatever they were coded to do - change colours on the screen, move / hide / show elements or groups of elements - perform calls back to the server (AJAX) etc - again no real limits on what can be done.

To answer your question - the content of a web page is HTML, media, styles and script - no variables.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
geeta_m9Author Commented:
Thank you for your detailed explanation, Julian. So in other words, the content should stay the same if the code was copied and pasted to a new page. However, the behavior and look and feel (formatting) would be affected if it uses AJAX, external JavaScript and stylesheets and images?
Julian HansenCommented:
So in other words, the content should stay the same if the code was copied and pasted to a new page.
If by cut and paste you mean from the source obtained by doing a "View Page Source" in the browser - then mostly yes - refer to Tom Beck's post ( where he highlights that if Javascript / jQuery / AJAX code changes the content of the page - this will not show up when you do a view source on the page - it will, however, show up in the console.

The View Page source shows you what html was originally sent to the browser - any changes made by javascript dynamically would not show in this view.

But in essence, yes, if you copy the source from the page source to another page the content should remain exactly the same.
geeta_m9Author Commented:
Thank you!
Julian HansenCommented:
You are welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.