471,336 Members | 1,262 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,336 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 2615
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by David MacQuigg | last post: by
13 posts views Thread by arreeess | last post: by
3 posts views Thread by Kalle Anke | last post: by
1 post views Thread by Armin Gajda | last post: by
13 posts views Thread by stephenpas | last post: by
5 posts views Thread by Nathan Sokalski | last post: by

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.