473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Style, But No Class


In a manner of speaking.

I just want to know if it is possible to style a page
without using the class attribute? If so, how is this
done?

Thanks.

Aug 24 '07 #1
9 2688
pbd22 wrote:
In a manner of speaking.

I just want to know if it is possible to style a page
without using the class attribute? If so, how is this
done?
Each HTML element has an implicit "style" attribute.

So this:
Expand|Select|Wrap|Line Numbers
  1. <style>#MyClass H1 {position:absolute}</style>
  2. <h1 class="MyClass">Hello World</h1>
  3.  
is functionally equivalent to this:
Expand|Select|Wrap|Line Numbers
  1. <h1 style="position:absolute">Hello World</h1>
  2.  
Aug 24 '07 #2
pbd22 wrote:
In a manner of speaking.

I just want to know if it is possible to style a page
without using the class attribute? If so, how is this
done?
Sure, but you'll end up with a tacky little tramp of a page.
Aug 24 '07 #3
Sanders Kaufman schrieb:
Expand|Select|Wrap|Line Numbers
  1. <style>#MyClass H1 {position:absolute}</style>
  2. <h1 class="MyClass">Hello World</h1>
  3.  
"#MyClass H1" selects H1 elements that are _descendants_ of _the_
element with the _id_ "MyClass", not h1 elements with _class_ "MyClass".

--
Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
(Thomas Tallis, 40-part motet)
Aug 24 '07 #4
Nik Coughlin schreef:
pbd22 wrote:
>In a manner of speaking.

I just want to know if it is possible to style a page
without using the class attribute? If so, how is this
done?

Sure, but you'll end up with a tacky little tramp of a page.

Assuming that we agree that tacky means tasteless,
are you implying that using classes guarantees good-looking pages?
And that the absence of classes will *always* result in tacky pages?

--
Rob Waaijenberg
Aug 24 '07 #5
In article <46*********************@news.xs4all.nl>,
Rob Waaijenberg <ro************@hotmail.comwrote:
Nik Coughlin schreef:
pbd22 wrote:
In a manner of speaking.

I just want to know if it is possible to style a page
without using the class attribute? If so, how is this
done?
Sure, but you'll end up with a tacky little tramp of a page.

Assuming that we agree that tacky means tasteless,
are you implying that using classes guarantees good-looking pages?
And that the absence of classes will *always* result in tacky pages?
Rob! It was a joke. And a nice one. It did not have any deep
implications.

--
dorayme
Aug 24 '07 #6
dorayme schreef:
In article <46*********************@news.xs4all.nl>,
Rob Waaijenberg <ro************@hotmail.comwrote:
>Nik Coughlin schreef:
>>pbd22 wrote:
In a manner of speaking.

I just want to know if it is possible to style a page
without using the class attribute? If so, how is this
done?
Sure, but you'll end up with a tacky little tramp of a page.

Assuming that we agree that tacky means tasteless,
are you implying that using classes guarantees good-looking pages?
And that the absence of classes will *always* result in tacky pages?

Rob! It was a joke. And a nice one. It did not have any deep
implications.
Oh, I'm sorry.....

--
Rob Waaijenberg
Aug 24 '07 #7
On 24 Aug, 03:31, pbd22 <dush...@gmail.comwrote:
I just want to know if it is possible to style a page
without using the class attribute?
Of course. Pages "get styled" pretty much by default, even if they
don't take any deliberate design action. Class just makes this more
flexible.

CSS can also be placed in style attributes on each element. It's
trivial to prove that:

* (Almost) any web page with a stylesheet can have it replaced by
style attributes.
* Any non-trivial page would require so much work to do this that it's
entirely impractical.

(Actually there's a couple of things you can't do without a
stylesheet, such as using selectors like :hover, or media-specific
CSS)
CSS in stylesheets attaches itself to the elements by the application
of "selectors". These can use various items to identify the relevant
HTML: element names, class values or id values being the most
obvious.

If you want all <pstyled the same, then just use the element name "p
{ }".

If you want one <p id="foo" to be different, you could use an id
"p#foo { }" (I'd still suggest class, but you certainly _could_ do
this).

If you want a recognisable set to be different, and the HTML structure
permits it, then you could use "div p { }" to identify only those <p>
that were inside a <div>.

If you want to address some set of <pthough, and none of the above
selectors are practical, then it's time to use a class. It's simple
to use and very flexible. You can even use it to hide the element type
such that ".warning {color: red;}" can be applied equally to <p
class="warning" or <h1 class="warning" >. It's a great tool for all
CSS use.
So why are you wondering if you can avoid it?

Aug 24 '07 #8
pbd22 <du*****@gmail.comwrote in news:1187922681.691672.62690
@i38g2000prf.googlegroups.com:
>
In a manner of speaking.

I just want to know if it is possible to style a page
without using the class attribute? If so, how is this
done?
I like your subject line. Reminds me of my mother-in-law.
Aug 24 '07 #9
Sounds like my ex...

Aug 24 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: David MacQuigg | last post by:
I have what looks like a bug trying to generate new style classes with a factory function. class Animal(object): pass class Mammal(Animal): pass def newAnimal(bases=(Animal,), dict={}):...
13
by: arreeess | last post by:
i wont used three styles in the element of a list; i have does so: <ul> <li> ............................. </li> first style <li> <p> .....................</p> </li> 2° style <li> <p...
9
by: lkrubner | last post by:
How do I get all the div's on a page? I realize in IE I can use document.all. For the other browsers, I need to get an array of all the divs on the page. getElementByTagName()?????
3
by: Kalle Anke | last post by:
I'm confused by the concepts of old-style vs new-style classes, I've read most of the documents I found about this but it doesn't "click". Probably because I wasn't around before 2.2. Anyway,...
38
by: looping | last post by:
For Python developers around. >From Python 2.5 doc: The list of base classes in a class definition can now be empty. As an example, this is now legal: class C(): pass nice but why this...
1
by: Armin Gajda | last post by:
Hi, I have the following problem: An input field get a border assigned by a style class (e.g. 2px solid red). When the field gets the focus, we set the border to green. element.style.border...
13
by: stephenpas | last post by:
We are trying to monkey-patch a third-party library that mixes new and old-style classes with multiple inheritance. In so doing we have uncovered some unexpected behaviour: <quote> class Foo:...
3
by: Michellevt | last post by:
Hi I am working on a project (for college) and wondered if anyone can help me with my problem. In the project we are not allowed to make use of any "style" attributes but "class" attributes...
5
by: Nathan Sokalski | last post by:
I have css that would normally be placed in style tags in the header of the Master page that I want to add programmatically for a specific Web Content Form (the *.aspx page). How do I do this for a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.