Category Archives: HTML / PHP

HR Style

The hr html entity needs to be styled with both color and background-color attributes to display the desired color in all browsers. It is also adviced to define border 0 for the hr in the style sheet.

Example:

 
hr {
color: #c7c7c7;
background-color: #c7c7c7;
border: 0;
margin-bottom: 1em;
margin-top: 1em;
}

PHP Code for current year

The current year is useful in applications such as copyright notices, typically used in footer of website. This is the simplest possible code for displaying current year:

<?php echo date('Y'); ?>

How to add a style sheet property to a sub element

Sometimes, for reasons that elude me, you can not use a class or an id for an element placed within another element that already uses a class or an id. To get around this you must define the element you want to style in your style sheet as a sub element of the principal class or id.

For example, if you want to have an image within a div and you want both the div and the image to use style sheet defined properties, then your style sheet should look like this:

.div {
define properties for the div
}

.div img {
define properties for the image within the div
}

You could also use id instead of class and it would then look like:

#div {
define properties for the div
}

#div img {
define properties for the image within the div
}