It is, but requires a CSS2 capable browser (all major browsers, IE8+).
.OwnerJoe:before {
content: "Joe's Task: ";
}
But I would rather recommend using Javascript for this. With jQuery:
$('.OwnerJoe').each(function() {
$(this).before($('<span>').text("Joe's Task: "));
});
Answer from Marcel Jackwerth on Stack Overflowhtml - Using CSS to insert text - Stack Overflow
Adding external css file to html doc
What's the easiest way to link HTML and CSS files for practicing?
Is there some sort of reddit CSS guide?
Check out the sidebar, and my snippet list:
http://www.reddit.com/r/csshelp/wiki/moresnippets
album form: http://imgur.com/a/549RO
More on reddit.comHow is CSS Different From HTML?
How do you add CSS to HTML?
How to put external CSS in HTML?
Videos
It is, but requires a CSS2 capable browser (all major browsers, IE8+).
.OwnerJoe:before {
content: "Joe's Task: ";
}
But I would rather recommend using Javascript for this. With jQuery:
$('.OwnerJoe').each(function() {
$(this).before($('<span>').text("Joe's Task: "));
});
The answer using jQuery that everyone seems to like has a major flaw, which is it is not scalable (at least as it is written). I think Martin Hansen has the right idea, which is to use HTML5 data-* attributes. And you can even use the apostrophe correctly:
html:
<div class="task" data-task-owner="Joe">mop kitchen</div>
<div class="task" data-task-owner="Charles" data-apos="1">vacuum hallway</div>
css:
div.task:before { content: attr(data-task-owner)"'s task - " ; }
div.task[data-apos]:before { content: attr(data-task-owner)"' task - " ; }
output:
Joe's task - mop kitchen
Charles' task - vacuum hallway
I feel stupid and like I have taking 3 steps back in my learning. I am trying to figure out the 3 different implementations of css. Doing External now. Just trying this super simple code, the colors did not show up in the browser like they did on w3schools.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Is it because I don't have a css file on my computer? Do I need to download one? Copy and paste from somewhere? I don't get it. I prefer building with the css and html on the same document because I haven't learned how to do anything else yet. I have been able to follow tutorials fine but for some reason, now it's not clicking.