Page 1 of 2 12 LastLast
Results 1 to 15 of 29

Thread: CSS in PHP include header and footer not working

  1. #1
    Join Date
    May 2014

    CSS in PHP include header and footer not working

    Hi I can't get my php include/header & footer to recognize my css.

    My header.php and css are in the same file so I don't believe it is a directory issue.

    I have tried to make a base to link to the root but that didn't work.

    My website is kirsteneaton.com/myWebsite/currentProjects.php

    I have tried everything I know to get this to work for 2 days.

    Thank you.

  2. #2
    Join Date
    May 2014
    The gurus will soon attend to you

  3. #3
    Link 404 -- did you take it down because you got it sorted?

    Really, it's unlikely it belongs in your footer, since the STYLE and LINK tags are only valid in <HEAD></HEAD>

    really though, without seeing the PHP that generates your markup, it's unlikely we can help you.

  4. #4
    Join Date
    May 2014
    Quote Originally Posted by deathshadow View Post
    Link 404 -- did you take it down because you got it sorted?

    Really, it's unlikely it belongs in your footer, since the STYLE and LINK tags are only valid in <HEAD></HEAD>

    really though, without seeing the PHP that generates your markup, it's unlikely we can help you.
    Thank you for your reply. No, it was never up. Were you able to view it privately. I'm sorry for not including my php...

    <?php include 'header.php'; ?>

    <!DOCTYPE html>
    <title>Current Projects with PHP, SEO, JQuery</title>
    <div class="content">
    <div id="box">
    <h4>Making a Blog in PHP</h4>
    <p>Client based database</p>
    <p>Building Website using SEO</p>
    <?php include 'footer.php'; ?>

  5. #5
    Join Date
    May 2014
    Oh no I didn't give you the proper file name.
    And I have a header.php and a footer.php

  6. #6
    Well, I should probably read you the riot act on the halfwit garbage known as bootstrap, the HTML 5 trash, stupid bandwidth wasting "modernizr" script, gibberish use of numbered headings, incomplete form, lack of media targets on your script LINK...

    But setting all that /fail/ at building a website before you even have content aside...

    404, file not found

    404, file not found

    The files don't exist. Did you mean to do:

    Remember, the relative path of an include be it JS or CSS is to the location of the PHP file, so this:

    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">

    run from this:

    results in this:

    Not this:

    Since it's not in the root, you'll need to uptree link if you don't want to re-adjust your directory structure.

      media="screen, projection, tv"
    I added in all the stuff you are missing on those incomplete LINK

    Though honestly, I advise against that -- it seems more like your directory structure is flawed since up-tree linking (../) is just sloppy coding and poor planning. I'd move any files users can call directly into the 'root' of the site's location, so that all LINK and SCRIPT tags point down-tree instead.

    Now, that said, your includes also appear to be busted since you've got more than one doctype, head and body... and really you might want to learn a bit more about how to write HTML before you start playing with PHP as to be brutally frank, your markup is bloated gibberish nonsense -- though that's typical of what happens the moment you drag bootcrap and HTML 5-tardery all over a website's carpets.

  7. #7
    Join Date
    May 2014
    Yeah, I'm new, I suck, I get it. Ugh....where do I start? To be a little defensive I created the header.php and footer.php after my header and footer.html didn't work. I thought bootstrap would be easy now I'm left with this mess. I'll be back after I try to make some of the changes you suggested and let you know. I promise I am not a bad person.

  8. #8
    Join Date
    May 2014
    Ok, I see what you are saying. I am going to change my directory. No I did not know that it has to be http://kirsteneaton.com/myWebsite/ph...tstrap.min.css. Did I tell you thank you for beating me up and helping me? Thank you, but I am sure we aren't finished here.

  9. #9
    Join Date
    Mar 2012
    I strongly recommend using PHP include files, but only AFTER you have learned to write good HTML and CSS. They give a much better structure and maintainability, particularly for larger sites.

  10. #10
    Join Date
    May 2014
    Hi. Ok, so I canned the whole bootstrap mess and i wrote my website by hand taking in all of you suggestitions for meta tags and SEO purposes, thanks!
    I changed my file directory to put the css, header and footer all in the php file with the my php pages. I still can't access the css when i pull up my php pages.
    kirsteneaton.com/website my code is:
    i left a copy of 1.css in the website file for now.
    What am i still doing wrong?

  11. #11
    Did you figure it out, because it's loading CSS here.

    that said you are missing a few parameters on your LINK... You have:

    <link href="1.css" rel="stylesheet">

    ... and that's only part of the story. You might be having trouble from omitting the TYPE attribute... to say that it's text/css

    ... and since that's a screen layout you should also have a MEDIA attribute saying what media target that is for -- being a screen layout that's typically "screen, projection, tv"

    It's also nice to name your stylesheet what they are for -- print, screen, handheld, aural... etc.

    Other than that you seem to be working OK, unless you're using some old browser that can't do flex-box -- like IE 9/earlier.

    Though combining like values in the CSS might help things, as would a reset since there's extra padding in IE and 'real' Opera around things. Semantic/logical heading orders might be in order too... but that's unrelated to your CSS not loading.

    Is that still a problem? If so, what browser and what OS? did you accidentally disable CSS somehow (like with the web developer toolbar extension?)

  12. #12
    Oh, and on this:
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    Those last two values REALLY shouldn't be declared, they break the ability to zoom in desktop Safari and ALL mobile devices. Maximum-scale and user-scalable should REALLY be avoided as they make mobile harder to use, not easier. For SOME reason some 'experts' out there are claiming this does something useful (they aren't clear what), but given that it screws up one of the most important tools for mobile accessibility -- zooming in -- I can't imagine it to be worth that penalty.

    <meta name="viewport" content="width=device-width; height=device-height; initial-scale=1.0" />

    Would probably be better for you. I'd also suggest:
    @media (max-width:600px) {
    	* {
    Which would probably fix whatever those extra viewport meta values have, without screwing up desktop browsers. The media query is there because tablets don't need those settings usually, and sending the webkit one to desktop safari -- again -- breaks the ability to zoom... the laugh being it does NOT impact Safari on mobile's zooming, making it one of the real "what the devil were they thinking" of these new values.

  13. #13
    Oh, and you might want to validate your markup -- you've got an unclosed DIV, a second href with no values on your anchor, it's actually a little surprising the layout works with those issues; but HTML is very forgiving -- sometimes I think too forgiving as it makes it WAY harder than need be to notice mistakes.

    Often makes me wonder if the XML guys have it right -- when there's an error just "stop dead" right where the error is instead of plowing on blindly hoping things work; it would make finding errors simpler, and motivate people to actually fix errors instead of shrugging and going "eh, close enough".

    Current SGML style behavior sure as shine-ola doesn't seem to make things easier on people just starting out.
    Last edited by deathshadow; 05-31-2014 at 11:13 AM.

  14. #14
    Join Date
    May 2014
    Ok, let me catch up and make all of these changes.
    But first let me get something straightened out. Should my files be:
    header and footer html or .php?
    should my css file be inside of my php file?

    Thank you so much, so much for your help.

  15. #15
    Join Date
    May 2014
    ok. I am ready to go. Fixed my div, fixed my <links> changed the name of my css. My file structure is:
    header.html footer.html and a
    php file with all of my pages.
    if you go to kirsteneaton.com and then click on references my references.php is displayed with out the css. (my same ole problem)
    my code is:
    <?php include('header.html')?>
    I am clueless.
    You know if we got married I could make you dinner and you could teach me coding? How about it?
    So what's my problem with this css? You said before that all php point upwards that i would need to put my css in the root?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.19166 seconds
  • Memory Usage 3,011KB
  • Queries Executed 13 (?)
More Information
Template Usage (37):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates