Thanks everyone for your replies.  You've certainly given me a lot to think 
about.

A couple of other points.  I'm sorry I've probably confused people with 
terminology.  

1. My use of the word "class" in this thread was ambiguous perhaps.  I 
understand that a CSS class and an OOP class are completely different things.  
In my use of that word in this thread, I meant the OOP meaning, not the CSS 
meaning.

2. My use of the word "list".  I probably should have said "table".  I meant a 
conceptual "list" like how in Apple's Finder, or Windows Explorer you can 
arrange your icons in list view.  In HTML/CSS you'd normally use a table for 
that I suppose, and indeed it is a table in my example code.  In my use of the 
word "list" in this thread I did not mean the HTML <ul> or <ol> list.  But then 
again, it was just an example.

So... apologies for any confusion.  And thanks again to those who've chimed in 
on this.  I'll do some more research and look into the suggestions that were 
made.

Cheers,
David.






On 10/03/2012, at 4:33 AM, David Thorp wrote:

> I've had a couple of private replies saying that this question is off-topic 
> because it's nothing to do with css.  If that's really the case, then I 
> apologise for the noise, but before we come to that conclusion may i just 
> clarify something...
> 
> I understand that php has an include function for including other php 
> files/snippets in a page, but the question below is more specifically asking 
> how to encapsulate all the CSS styling along with the html code to make my 
> list "class".
> 
> It occurs to me now that perhaps in-line styles is the way to do that, but 
> I'm led to believe that in-line styles are, while possible, not good 
> practice...?  So what I'm really asking here is not just what's possible, but 
> also what's best practice* or common practice*, particularly relating to the 
> CSS part of this encapsulation concept.  Is this something people do 
> normally?  If so, what's the usual/normal way of going about it? Or is this 
> just not normal/sensible?
> 
> If, despite the above clarification, this question is still off-topic, then 
> again, I apologise.  Please feel free to tell me, and I'll pipe down :)
> 
> Thanks!
> David.
> 
> 
> *in a similar way to how I've learnt recently, for example, (thanks to people 
> on this list) that it's best not to use tables for layout.
> 
> 
> 
> 
> On 09/03/2012, at 9:17 PM, David Thorp wrote:
> 
>> 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: 
>> http://www.davidthorp.name/testingstuff/ghodmode-a.html).  
>> 
>> 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 
>> http://www.davidthorp.name/testingstuff/browser-0c.html).
>> 
>> 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?
>> 
>> If not, is this where I need PHP?  Can I achieve the above with PHP?
>> 
>> 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?
>> 
>> 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 [css-d@lists.css-discuss.org]
>> http://www.css-discuss.org/mailman/listinfo/css-d
>> List wiki/FAQ -- http://css-discuss.incutio.com/
>> List policies -- http://css-discuss.org/policies.html
>> Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
> 
> ______________________________________________________________________
> css-discuss [css-d@lists.css-discuss.org]
> http://www.css-discuss.org/mailman/listinfo/css-d
> List wiki/FAQ -- http://css-discuss.incutio.com/
> List policies -- http://css-discuss.org/policies.html
> Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

______________________________________________________________________
css-discuss [css-d@lists.css-discuss.org]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to