473,542 Members | 10,907 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2699
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
3800
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={}): class C(object): pass C.__bases__ = bases dict = 0
13
2790
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 class:"mystile">..... </p> </li> 3° style ... </ul> the call to class
9
12507
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
1271
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, the reason for new style classes are to make the whole type/object thing work better together. There are a number of new features etc. I think my...
38
2007
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 syntax return old-style class, same as "class C:", and not the new style "class C(object):" ?
1
15315
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 = "2px solid green"; When the field looses the focus, the border should change back to red.
13
2472
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: pass class Bar(object): pass
3
1897
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 instead. The following is the java script that i am using and i am having trouble in using a class instead of a style tag because simply replacing the...
5
3710
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 Web Content Form? I cannot use style tags in a Web Content Form, and I am having trouble figuring out how to add all the desired css properties to...
0
7384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7322
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7567
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7665
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5862
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5239
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.