General HTML/Web Design Programming Q`s/HTML and CSS

Advertisement


Question
I use this code to set Text Style
<P style="font-family:times new roman font-size:100%;">

But if I did the basic
<P font family="times new roman" font size="100%">

Would this not work?

I am going so nuts with every time the CODEs change. I am just getting more and more mixed up.

Thanks for the help?

Answer
Hi,

You must indicate the font-family property:
p {
   font-family: "Times New Roman", Times, serif;
}

Use the (:) and not the (style =)

I would also set the font size in (px) value or (em) value but that is a personal choice. You may use a combination of Percentage and Em:

EXAMPLE:

body {
   font-size: 100%;
}

h1 {
   font-size: 2.5em;
}

h2 {
   font-size: 1.875em;
}

p {
   font-size: 0.875em;
}


Furthermore, I do not recommand the use of CSS within a selector. It makes no sense to add styling to each and every HTML selector. For example all the P selectors would have to be styled individually.

The first rule of coding is to separate content (HTML) and style (CSS).
You can place the style in the Head section or in a separate expernal style sheet. I would recommand the external style sheet (I sometimes use the head section then copy and paste the CSS code in an external style sheet).

In short,
There are three ways of inserting a style sheet:

External style sheet
Internal style sheet
Inline style

1. With an external style sheet, you can change the look of an entire website by changing just one file! Changing any selector in a single operation (e.g. all the paragraphs)

2. An internal style sheet may be used if one single page has a unique style.

Internal styles are defined within the <style> element, inside the <head> section of an HTML page:

EXAMPLE
<head>
<style>
body {
   background-color: linen;
}

h1 {
   color: maroon;
   margin-left: 40px;
}
</style>
</head>

3. An inline style may be used to apply a unique style for a single element.

To use inline styles, add the style attribute to the relevant element. The style attribute can contain any CSS property.
Example:
<h1 style="color:blue;margin-left:30px;">This is a heading.</h1>



I Hope this help. If not go to http://www.w3schools.com/css/css_font.asp. It has all updated informations  for ALL web design codes.

General HTML/Web Design Programming Q`s

All Answers


Answers by Expert:


Ask Experts

Volunteer


Gaston Michel Côté

Expertise

Anything related to web design, gamification, color psychology, and ELearning. Codes: HTML5, CSS3.

Experience

Three years as a web consultant and designer

Organizations
Self-employed

Education/Credentials
College Education Certificate in Multimedia Productions

©2016 About.com. All rights reserved.