does the PHP code run independant of CSS?

Posted on 2005-04-13
Last Modified: 2013-11-19
Newb question about how PHP works with formatting on a page..

If I have PHP code developed for me by a web programmer.. for siteA, can I take that same code and use it with siteB, which has a different "look and feel" to it then siteA ?  i am trying to understand how php works in regards to the look and feel of a page.. tables, color and font schemes, etc...

I want to have a Portfolio section developed for a web site that would show Completed Jobs, and Work in Progress on siteA
Assuming the contract with the developer is written so that this is possible contracturally, I would like to then take that code and use it on siteB that will also have a Portfolio section....


Question by:pdxsrw
    LVL 29

    Accepted Solution

    The ideal would be that your layout (CSS) is separate from your content (HTML)

    If your contractor does not embed layout in the HTML it will be relatively simple to change the style for a different site.  Probably the best example I know of is CSS Zen Garden, where one site has been customized with different styles from many different web designers. ( It is amazing to see how dramatically different a site can be just by changing the CSS.

    With CSS there are three ways to refer to the markup so you can assign a style.  By HTML tag, by the element's ID and by the element's class.

    Your contractor will need to make sure that the underlying HTML properly exposes the various HTML elements to CSS by proper use of one of those three methods.  As long as that is the case, you should be okay.

    One way to help specify what you expect, is to specify that the HTML validates properly to HTML 4.01 strict recommendations and uses no obsolete or depreciated tags.  (  You should also specify that except for columner data (such as a stock chart, or other data grid) that no tables be used to achieve page layout.

    All of that background and no mention of PHP????

    PHP is a server side scripting language.  It has nothing to do with output, except what the author causes it to write.  So if you specify the above, any output rendered via PHP will need to comply as well.  CSS does not take effect until the page is rendered.  Anything done with PHP will be completed before the CSS becomes effective.  (e.g. at that point you simply have HTML output, the PHP processing is complete.)

    Good Luck,
    LVL 20

    Expert Comment

    rdivilbiss's answer summarizes the factors involved in a PHP, HTML (or XHTML), and CSS solution.

    PHP itself can control server-side output, meaning it can write HTML files (and CSS and JS files for that matter)

    depending on the contents of these HTML files, you might be able to control what the pages look like... but to varying degrees.

    CSSgarden is an example of a place where this is done powerfully.  Depending on whether you just want to change colors or whether you want to change entire layouts, you might be creating quite a headache in terms of writing HTML that will be completely re-arrangeable via CSS.

    one major problem is that even today, much of the code out there is formatted in tables.  And I, for one, have never been able to completely control every aspect of the organization of a page that's table based.  if you're lucky, they'll use DIVs for most things, which will give you more freedom of arrangement (if that's what you're looking for).
    LVL 1

    Expert Comment

    CSS defines styles for a browser (IE, Firefox, Netscape). Anything that is processed at the browsers end (your computer) is called "client side" so CSS would fit in this definition.

    But PHP isn't, it is server side: anything that is processed at the servers end (where the website is kept). The servers preprocesses the PHP code, and then it is sent to your browser in HTML format, thats why it is impossible to view a PHP code on a browser (all you will see is HTML).

    So when using SiteA PHP code in SiteB, other parameters rather than CSS should be considered: PHP default configurations (example..cookies and sessions are available on SiteA but not on SiteB), database connectivity and configuration (if SiteA php codes connects to a MySQL engine, then SiteB must have it too unless there is a configuration file where a Database is defined and can easily be switched).

    The only dependance I can see between PHP and CSS would be for example that the programmer, knowing that most users (clients) will be using IE or Netscape, outputs CSS code using PHP:

    echo "<STYLE>   A:hover......"  

    I understand that the hover attribute works with Explorer and Netscape 6.x, so using a different browser might result a different looking page.

    You make search through Google for CSS compatibility among browsers.

    if your PHP code works smoothly, CSS becomes it only gives better aesthetic looks.

    LVL 29

    Expert Comment


    Thank you.  Good luck with your project.


    Featured Post

    Training Course: Adobe Photoshop CC 2015

    Photoshop has become the standard in image manipulation among professional photographers and graphic designers. This course covers exam objectives for the Adobe Certified Associate (ACA) certification.

    Join & Write a Comment

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now