Cascading Style Sheets in XHTML 1.0 STRICT

  • HTML/CSS
  • Thread starter jeff1evesque
  • Start date
In summary, the conversation discusses creating a webpage located on a server, utilizing a parent directory called public_html and a subdirectory called CSS. The webpage has a file called assign5A.html that uses another file called mystyles.css. The conversation also mentions creating a class called "body" to encapsulate the webpage's body and making changes to the background color, text font, and color. The proper syntax for the CSS file is discussed, along with the purpose of the "rel" and "type" attributes in the HTML code. The conversation ends with the solution being found for the initial problem.
  • #1
jeff1evesque
312
0
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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

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

<body class = "body">
.
.
.
</body>
</html>


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

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:
Technology news on Phys.org
  • #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.
 
  • #3
I tried it, doesn't seem to work. But I think you are correct, I'll play around with it.Thanks a lot,JL
 
  • #4
"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.
 
  • #5
Thanks for the help guys. I found the solution to my problems.
 

FAQ: Cascading Style Sheets in XHTML 1.0 STRICT

What are Cascading Style Sheets (CSS) in XHTML 1.0 STRICT?

Cascading Style Sheets (CSS) is a style sheet language used to define the presentation of a document written in XHTML 1.0 STRICT. It allows web developers to separate the style and layout of a webpage from its content, making it easier to maintain and update.

How do I link a CSS file to an XHTML 1.0 STRICT document?

To link a CSS file to an XHTML 1.0 STRICT document, you can use the <link> tag in the <head> section of your document. The <link> tag should contain the rel attribute set to "stylesheet" and the href attribute set to the location of your CSS file.

What is the difference between inline, internal, and external CSS?

Inline CSS is when the style rules are written directly in the HTML element's style attribute. Internal CSS is when the style rules are written in the <style> element within the <head> section of an XHTML document. External CSS is when the style rules are written in a separate CSS file and linked to the XHTML document using the <link> tag.

Can I use CSS in all versions of XHTML 1.0 STRICT?

Yes, CSS can be used in all versions of XHTML 1.0 STRICT. However, some CSS properties and selectors may not be supported in older versions of browsers, so it is important to use CSS in a way that is compatible with the web browsers you are targeting.

How can I override CSS styles?

To override CSS styles, you can use the !important declaration after the style rule. This will give the style rule the highest priority and override any other style rules applied to the same element. You can also use more specific selectors or use inline styles to override existing styles.

Similar threads

Replies
9
Views
2K
Replies
2
Views
1K
Replies
2
Views
1K
Replies
3
Views
2K
Replies
4
Views
2K
Replies
3
Views
3K
Replies
3
Views
9K
Back
Top