Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Foundations Values and Units Numeric and Textual Data Types

SAMUEL LAWRENCE
PLUS
SAMUEL LAWRENCE
Courses Plus Student 8,447 Points

What's the difference between numeric data types, numeric value types and URL data types?

Hi, in this video lesson Guil uses a lot of different terminology to describe certain properties and I'm not sure what they mean. He uses numeric data types numeric value types and URL data types. are these all the same or is numeric value type and URL data types a subset of Numeric data types? Can they be used interchangeably, I mean the terms?

Also he explained what double quoted strings are, but what I don't fully understand is, why use double quoted strings when clearly he could have used a normal paragraph element. So that raised these questions. What are double quoted strings normally used for, and what type of content would you normally place in them? In what situations would it be better to use a double quoted string?

Finally he said that you cannot use double quotes inside a double quoted string unless you escape them with a backslash. What does escape them mean in this instance? I know what escape mean, but I don't understand how it is used here. What does escaping them mean really? Oh and why can't double quoted strings contain double quotes without having to escape them? is it cause they won't render or will they cause some other kind of problem(s) in your code?

7 Answers

There are many numeric data types such as:

  • Integers - Whole numbers only, no decimals.
  • Numeric and Decimal - Both the number of digits before and after the decimal may be specified for precision.
  • Float and Double - Decimal place is not fixed and precision is accurate only to a significant number of digits.

URLs are not typically represented by numeric data types but rather as strings since they use alphanumeric characters.

You have to use single quotes or double quotes when referencing strings. Both are valid and use is a matter of preference and convention.

In the case of a single quoted string you can use double quotes within the string but you cannot use an apostrophe (as that would signal the closing of the single quoted string).

In the case of a double quoted string you can use single quotes or apostrophes within the string but you cannot use double quotes (as that would signal the closing of the double quoted string).

Consider this sentence: "Captain," said Scotti, "I'm giving her all she's got!"

A single quoted string would need two characters escaped (the apostrophes in I'm and she's). JavaScript code for defining a string variable would be:

var myString = '"Captain," said Scotti, "I\'m giving her all she\'s got!"';

Double quoting the string would require escaping the four double quotes:

var myString = "\"Captain,\" said Scotti, \"I'm giving her all she's got!\"";

In the second example it would not be necessary to escape the apostrophes.

Bob Sutherton
Bob Sutherton
20,160 Points
selector {
      property: value;
}

Single or double quotes are arbitrary. You can use either, but if you have a set of double quotes inside of another set of double quotes it will break apart for obvious reasons. It will just become two separate strings instead of a set of quotes inside of a string. Hence, you have to use the backslash to escape (a computery, programmy way of saying it) - in plain terms, make the inside quote marks not associate with the outside quote marks that surround your string value.

I understand your confusion about him using the content property. It is not something I have used a lot myself, but I have seen it used at least one time. That was when a blockquote needed a set quotations added to it (i think it was an image, so content property doesn't always have to be just text) like you have probably seen before. This was done with the content property. I'm sure there are plenty of more cases when the content property is used but I am not experienced enough to have encountered it much. I would say this is something you can look more into if you are interested or you can just cross that bridge when you get there.

If you want to look more into it try looking it up on w3schools.com

The data types are just kinds of data that are used for the value. Like text or numbers. Text is just a bunch of data. Numbers are just a bunch of data. They are different types of data though. One is a number the other is text. Both types can be used as values for CSS properties.

This stuff can get confusing, especially the way things are worded. In my opinion, overly complex wording often makes simple things more difficult than they should be. I hope what I have said here is helpful and correct.

SAMUEL LAWRENCE
PLUS
SAMUEL LAWRENCE
Courses Plus Student 8,447 Points

Hi guys, thanks for the quick replies. That was immensely helpful. Both Brock, and Phil. That made a lot of sense to me, and thanks for the example Phil. I guessed a few of the things you said, but since I'm new to this, this is the furthest I've gotten in HTML and CSS, I just wanted to be sure. As you said Brock, "overly complex wording often makes simple things more difficult than they should be" That is so freaking try. I know jargon are important, and necessary but sometimes, it really complicates things. Thanks again for the help guys. you rock!

Jane Marianne Filipiak
Jane Marianne Filipiak
7,444 Points

Hi Samuel,

Being a beginner too, I can only suggest that you look into the 3 css values Guil mentions: auto, inherit and initial. If you investigate what values are linked to 'auto', then the other two, you clarify all the confusing jargon.

Hope this helps, Jane

SAMUEL LAWRENCE
PLUS
SAMUEL LAWRENCE
Courses Plus Student 8,447 Points

Thanks Jane I will do that. As you know there are lots of info about these online, but most of them are not always explained in a way that a beginner can grasp. Would you happen to know a site where it's broken down in a way that is easy to digest? thanks

Jane Marianne Filipiak
Jane Marianne Filipiak
7,444 Points

Hi Samuel,

Perhaps W3C, which you can google, will have articles on these details re CSS.

Re myself, I will just have to dive into the CSS 'deep-dive' several times before I can figure it all out.

Jane