Previous Message
Next Message


Sent by Ghodmode on 10 March 2012 15:03

On Fri, Mar 9, 2012 at 6:17 PM, David Thorp
> Greetings all... again... ;)
> I'm familiar with some concepts from object oriented programming.  In particular something which i
think is called encapsulation.
> In languages like C++ you build classes which are portable mini programs that do stuff.  You can
pick them up and plug them into any C++ program, you don't have to know how it works, you just know
what it does and its input and output and you can just use it without any fuss.
> I'm looking at how HTML and CSS work, and wondering if there's some way to do similar things like
this in web development.  I understand javascript and php are both object oriented languages, but
I'm just talking about html and css.
> For example... with the help of Vince (ghodmode) and a couple of others on this list I have built
a really nice simple list layout.   (see:
> Say I know want now to pick that list up and put it somewhere in the middle of another larger page
(something with a lot more stuff in it, say
> Or more accurately, I want to pick that list up and put different versions of it (ie. same layout
but perhaps different numbers of columns, different alignments in each column, etc) into various
locations in a more complex layout.
> Ideally I want to keep that list in it's own file and just refer to it from the main file.  I
don't want to have to copy and paste the code from the list file into the main file.
> If this was C++, that would be relatively simple.  The class would have methods that you can call
with different parameters for different situations (eg. number of columns, alignment in each column,
whatever).  You then add a #include statement at the beginning of your main file, that effectively
makes the class part of your program, and you call it from the main file with method calls and
parameters, in each different situation.
> So... my question is... Is this possible in web development  at all?
> Is it possible just with plain HTML and CSS files?

I'm not up to date with OO lingo, so I'm not sure if this is encapsulation

HTML and CSS doesn't really comprise of a complete programming language, but
there are _conventions_ that make it possible to create reusable HTML and CSS

I emphasize the word "conventions" because there aren't any rules or controls in
place to help you do it right.

What I think you want to look at and learn is OOCSS.  It can get pretty complex
and without those controls in place, it's all on your discipline as a coder to
do it right.

The GitHub Wiki:

The presentation:

Or just the slides:

YouTube to the rescue:

> If not, is this where I need PHP?  Can I achieve the above with PHP?

PHP isn't necessary, but it does make this kind of thing easier.

> And if the answer to that is no, then is there any way to achieve this concept at all? Or am I
just barking up the wrong tree here?

There's a million ways to achieve this in web development.  They're all the
right tree for someone.  You just need to find the right tree for you...  Get to
barkin'... I think that means you have to start reading a lot.

Vince Aggrippino
Ghodmode Development

> Thanks!
> David.
> PS. for what it's worth the data in the records/rows in the list are ultimately going to be
generated dynamically by PHP or other calls to a database, so the above question is only really
about the table, the divs, and the css styling, not the data in the list. Hope that makes sense.
css-discuss [EMAIL-REMOVED]]
List wiki/FAQ --
List policies --
Supported by --
Previous Message
Next Message

Message thread:

Possibly related: