Solved

<STYLE> not working

Posted on 2006-10-27
6
263 Views
Last Modified: 2010-04-09
Based on what I'm reading in my HTML tutorial self-guide, I think the simple code below should run in my browser, but the <STYLE></STYLE> portion has no affect at all.  What am I doing wrong>>>

Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Scripting Demo

<STYLE>
      <H3>{text-align: center}
      <P>{Color: #FF0000; font-style: Italic}
</STYLE>

</TITLE>
</HEAD>
<BODY>
<H3>This is a heading</H3>
<P>
This is a demo for using a style.
</P>

</BODY>
</HTML>
0
Comment
Question by:rlsokoloff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 54

Assisted Solution

by:b0lsc0tt
b0lsc0tt earned 63 total points
ID: 17822942
rlsokoloff,

Your style block needs to look like this instead.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Scripting Demo

<STYLE>
     H3 {text-align: center}
     P {Color: #FF0000; font-style: Italic}
</STYLE>

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 17822962
I normally make it more readable by doing something like the example below.  Notice the element you identify in the style block is NOT in html tags (i.e. < or >).

h3 {
  text-align: center;
}

p {
  color: #ff0000;
  font-style: italic;
}
0
 
LVL 1

Accepted Solution

by:
cheetahshrk earned 62 total points
ID: 17822969
You wrote the css incorrectly, remove the < and > around the H3 and P in the style tags so it is
<STYLE>
     H3 {text-align: center}
     P {Color: #FF0000; font-style: Italic}
</STYLE>

Also, the </TITLE> needs to be moved to after the title and not after the style tag.
So it becomes <TITLE>Scripting Demo</TITLE>

In the end, your html file should look like this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Scripting Demo
</TITLE>

<STYLE>
     H3 {text-align: center}
     P {color: #FF0000; font-style: Italic}
</STYLE>

</HEAD>
<BODY>
<H3>This is a heading</H3>
<P>
This is a demo for using a style.
</P>

</BODY>
</HTML>
0
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 17822981
Good catch on the title tag, Cheetahshrk.  I missed it.  Thanks!
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 17823222
I'm glad that I could be one of those that helped you.  Thank you for the grade, the points and the fun question.

bol
0
 

Author Comment

by:rlsokoloff
ID: 17835520
I made a comment when I awarded points, but I see it didn't get posted.  Anyway here's basicly what it was.

Thank you to both!  I caught the bracket problem when b0lscott posted, but cheetahshrk explicitly pointed out the issue minutes later.  Also, as a bonus b0lscott's formatting suggestion was very helpful, as well as pointing out to move the </TITLE>  tag (required to work)..

Thanks again!
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

717 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