General Question

johnny0313x's avatar

Why is the word pseudo often used when referring to CSS or maybe all code?

Asked by johnny0313x (1860points) January 7th, 2009

I keep seeing the word pseudo and no matter how much i read, i don’t really get why its being said everyplace, can anyone elaborate on this for me – doesn’t pseudo mean fake or pretend, not real, or representing something?

Observing members: 0 Composing members: 0

13 Answers

richardhenry's avatar

Could you give us an example? Generally when people say pseudo code, they’re referring to code that isn’t actual code, but is explaining how code statements work. Such as:

if (the cat is wet)
{
meow anxiously;
}

johnny0313x's avatar

http://www.cssbasics.com/chapter_18_css_pseudo_elements.html

that page

but ive seen it a few other places and what you said richardhenry makes sense out of the other places ive seen it.

MrItty's avatar

What richard says is true, but not applicable to the CSS definition. A CSS “pseudo element” is a thing that you can pretend is an real HTML element in your CSS code, but really isn’t. Real elements correspond to tags in HTML: the p element is the <p> tag. The div element is the <div> tag. Etc.

A pseudo-element is not an HTML tag. It is used to take out a piece of a real element. For example, “first-line”. There is no ”<first-line>” tag in HTML. However, you can say
p:first-line { color:red } to make the first line of any <p> tag’s text red. There is nothing in the HTML distinguishing this line from anything else. It’s just CSS allowing you to pretend that your code looks like this:
<p><first-line>this is the first line of text</first-line>
this is the second
and third
lines of text</p>

johnny0313x's avatar

css is making more and more sense to me…but honestly who comes up with this stuff…i mean at certain times it seems a little unstable. Not to mention and I realize the benefit of applying to to multiple pages or areas on a page but so much text to make a word italic and in html its a simple <i></i> given you need to put it in multiple locations but couldnt they have used the same tag for CSS or maybe made a small variation like <ii></ii> or something?

MrItty's avatar

<i></i> isn’t real HTML to begin with. It’s a netscape-ism. The official way to create emphasized text is <em></em>. But I digress.

The point of CSS is to be able to design your entire website with a consistent layout, and more importantly, to easily change that layout.

Let’s say your website – all 50 pages of it – uses <i>Title</i> whenever talking about the title of a book. Now a year later, you decide (or are ordered) that titles should be bolded instead of italicized. You have to go through all 50 pages, and search out every single instance of a title to change <i>Title</i> to <b>Title</b>. You can’t even do a ReplaceAll in your favorite text editor, because you don’t necessarily want all Italics changed to Bold, you only want titles to be bolded.

Now go back. Let’s say you’d used CSS in the first place. You use HTML to structure your content, and CSS to format it. So all of your titles are in the HTML as <span class=“title”>Title</span>. Yes, that’s a hell of a lot more typing when you originally created it. But now, all you have to do is change one line of one file:
.title { font-style:italic }
to
.title { font-weight:bold }

Save that CSS file, and you’re done. Every single title is now updated with your new format.

As for why we have this large difference, it’s because of the history of HTML. HTML was originally intended as a content-structuring language (“mark-up language”), nothing more. This is the title, this is a paragraph, this is emphasized text, etc. It said nothing about how the resulting content should look. Then Netscape came along and said “we have full-graphics browsers now. Let’s make the web pretty in addition to structured!”. So they created additional tags like <i>, <b>, <u>, etc. Those tags became so widely adopted that all browsers now support them. They also made maintaining a complex website difficult, and they made HTML into a conglomeration of both structure and format.

Eventually the W3 committee said “Enough is Enough!” and made the next-generation version of HTML. XHTML further restricts the original HTML standard, to make it even more just about structure. And to satisfy the need for formats as well as structure, they created CSS to work hand-in-hand with XHTML.

Is it more complicated? Yes. And that’s the point. It’s specifically designed for complicated websites. If you’re just wanting to write a little snippet for your myspace page or your own personal one-page website, feel free to completely ignore CSS and use all the b, i, and u tags you want. But if you want a professionally done complex website, CSS is by far the way to go.

richardhenry's avatar

Oooh, I glossed over the CSS part. Apologies.

cat = not wet;

johnny0313x's avatar

@mritty – very well put, that makes sense to me, plus i guess it makes web design more of a skill then it was before, knocking out some of the people from that field who won’t bother to learn new standards and creating more jobs and opportunity for those who are willing to go the extra mile and learn lol.

It does make sense to me to do things this way but does this mean there could be a new standard besides CSS that Netscape might throw out as some kind of battle, “like yeah bitch we started this and we are gonna end it!” I mean browsers all do whatever the hell they want…im surprised they all haven’t came up with their own code yet just to make life hard. I honestly think a lot of things on the internet need to be standardized for functionality sake.

On another note how does someone even define how a code reacts I mean what really makes <b></b> make the text darker or <hr> draw a horizontal line across the page. What defines this. I mean how can i just say <ggf> is going to make a big X on the page. Does anyone get where I am going with this?

Perchik's avatar

@johnny.

You really don’t want something along with css to come out. RIght now css has standards, that browsers should apply. That is. In css, font-weight:bold, means that the font needs to be bold. A standards-compliant browser should see that and make the font bold. That’s the point of standards. A new styling language would just be terrible.

Another benefit of css is that you can assign multiple stylesheets to be handled when you do different things. For instance, you can assign a stylesheet for printing, so that when the user prints all they get is text instead of big images. You can assign stylesheets for handheld devices, so that when someone looks at your site with a handheld browser (iPhone, palm pilot..etc) they see something that is optimized for a small screen.

A final benefit of CSS is accessibility of the HTML. If the HTML is clean and makes sense (like I mentioned in the other question) it becomes much easier for assistive technologies to “read” your page. That’s one of the big reasons I’m very picky about using markup that makes sense, instead of throwing things in for style purposes.

As far as your second question, the browser handles the code. It has been programmed how to handle different elements. It knows that <div> is a block element, so it has a new line after it. However, with css, the default styling of an element can be overridden. (Btw, <b><i><u> are non-standard elements now. Without a stylesheet turned on you really just want text)

Xhtml is a subset of XML. Xml is “eXtensible Markup Language.” The idea behind XML is that you can right any tag you want. From there, you would have to do something to parse (understand) that XML. A browser is programmed to interpret XHTML, html, and a host of other langauges. However, by default most browsers just display xml as text. If you really wanted to write in xml, you’d have to have some method of defining what the code means.

You’re much better off just using XHTML and CSS. You really can strip the default behavior from all elements if you want to. Which means that if you want an element to always show as a big X, you could do that through CSS.

MrItty's avatar

@johnny – the browsers are still coming up with their own crap. Of course, Netscape is dead and buried, but we now have Internet Explorer, Firefox, Opera, Safari, etc. IE is the biggest offender. It doesn’t follow the standards for javascript, for example. Instead it follows its own proprietary javascript-like thing they call jscript. It forces web designers to jump through hoops writing code that boils down to:
if (this_is_IE) {
do jscript code
} else {
do real javascript code
}

Except that it has to be written in both javascript and jscript, with kludges that make IE ignore the javascript and all others ignore the jscript. It makes life for web developers incredibly annoying.

So no, you don’t have any guarantees at all. The best you can do is use whatever features are available to you to make your life as painless as possible.

Perchik's avatar

@mritty I’ve the only time I’ve had a javascript problem in IE was when I tried to use a variable named “class” which is an IE reserved word. To be fair, I’m programmer and I shouldn’t have named a variable “class” to begin with. Other than that, I’ve done some fairly heavy stuff in javascript and never noticed an issue. PM me with specifics? [I figure, he’s talking about css and xhtml, no need to bog him down with javascript too]

johnny0313x's avatar

yeah, keep your bog away from me! heh JK

MrItty's avatar

[pm sent]

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther