Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Cascading Style Sheets in XHTML 1.0 STRICT

  1. Mar 19, 2009 #1
    I am creating a webpage that is located on a server, where the parent directory is called public_html. In this directory, I have the file called assign5A.html that will be the web page seen on the browser. This file utilizes another file located in a subdirectory- public_html/CSS- and is called mystyles.css.

    I am trying to create a class called "body" which will encapsulate the entire body of the page. I am going to try to set the background color along with the text font and color. So in the beginning of the assign5A.html I have written the following (notice it is written in XHTML 1.0 strict):

    <?xml version = "1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <title>CS403 Spring 2009 Assignment 5</title>
    <link type = "text/css" rel = "stylesheet" href = "CSS/mystyles.css" />

    <body class = "body">

    **This entire source code can be viewed at http://pubpages.unh.edu/~jmm42/assign5A.html** [Broken]

    Now in the file public_html/CSS/mystyles.css, I have written the following to specify the necessary changes(and I changed the permission to -rw-r--r--):

    <!-- File includes rules to add presentation details to assign5A.html -->

    .body {background-color: #0000FF;}

    I'm pretty sure I was told that in the CSS file I had to put a period character before the class name, with brackets following containing attribute properties inside it. Oh yea, I never understood what type, rel stood for in the code <link type = "text/css" rel = "stylesheet" href = "CSS/mystyles.css" />
    Last edited by a moderator: May 4, 2017
  2. jcsd
  3. Mar 19, 2009 #2
    You don't need to name the body tag. It's already unique and only used once. So get rid of the class attribute and delete the period in front of it in the css file.
  4. Mar 19, 2009 #3
    I tried it, doesn't seem to work. But I think you are correct, I'll play around with it.

    Thanks a lot,

  5. Mar 19, 2009 #4


    User Avatar
    Science Advisor
    Homework Helper

    "rel" is the relationship between the current (XHTML) file and the linked file. In this case, the file is a style sheet, so it is coded rel="stylesheet".

    Type gives the MIME type. Other types: text/plain, text/html, application/xhtml+xml, application/octet-stream, image/jpeg, image/png, etc.
  6. Mar 19, 2009 #5
    Thanks for the help guys. I found the solution to my problems.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook