PDA

View Full Version : what does this code mean?


dreamweaver beginner
10-09-2009, 09:50 PM
Hello,

Could someone tell me why there is an exclamation point structure in this code? I don't know why it begins with <!-- and ends with -->


<!--
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #33FF33;
margin: 0;
padding: 0;
text-align: center;
color: #000000;
}
.oneColFixCtr #container {
width: 780px;
background: #FFFFFF;
margin: 0 auto;
border: 1px solid #000000;
text-align: left;
}
.oneColFixCtr #mainContent {
padding: 0 20px;
}
-->


I'm trying to create a simple situation where the main web page is in a box that takes up about 80% of the screen, and then all of the background on the edges is a darker color. This looks like good code to work with to achieve that goal.

coloeagle
10-10-2009, 01:27 AM
It is used to contain comments, notes or instructions in the html page. Does not display on the page.
Looks like you are wanting to use the styles you have for the page layout. If so you need to place them inside the style tag and not a comment tag.

Place the style tag inside the head section of the page and your styles inside the style tag.

<style type="text/css>
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #33FF33;
margin: 0;
padding: 0;
text-align: center;
color: #000000;
}
.oneColFixCtr #container {
width: 780px;
background: #FFFFFF;
margin: 0 auto;
border: 1px solid #000000;
text-align: left;
}
.oneColFixCtr #mainContent {
padding: 0 20px;
}
</style>

DWcourse
10-10-2009, 06:27 PM
But I believe it used to be necessary (and is often still done by Dreamweaver for instance) to put the actual styles in a comment to hide them from old, non-styles-aware browsers:

<style type="text/css">
<!--
.test {
color: #000;
}
-->
</style>

If that's what you're seeing, don't worry about it. It's really unnecessary at this point but doesn't do any harm (as far as I know).

domedia
10-12-2009, 12:22 AM
Do anyone know which browsers require the HTML comments in there in order for the page to properly handle the CSS?

If it's a browser older than IE6, I think most of us can start committing those comment codes as the page won't work in those browsers either way ;)